public function testCreateConsumerFromXML()
 {
     $xml = file_get_contents(__DIR__ . '/../samples/consumer.xml');
     $sxe = new \SimpleXMLElement($xml);
     $xmlElement = $sxe->consumer;
     $correctConsumer = new Consumer('f4e3c8b7f1c0b57a2313bd92dbeff7c2', '94238234899842389743298897247892', 'testchannel');
     $this->assertEquals($correctConsumer, Consumer::parseFromXml($xmlElement));
 }
 /**
  * @param \SimpleXMLElement $xmlElement
  * @return Token
  */
 public static function parseFromXml(\SimpleXMLElement $xmlElement)
 {
     $token = new self();
     if (!empty($xmlElement->token)) {
         $token->setToken((string) $xmlElement->token);
     }
     if (!empty($xmlElement->tokenSecret)) {
         $token->setTokenSecret((string) $xmlElement->tokenSecret);
     }
     if (!empty($xmlElement->user)) {
         $userObject = User::parseFromXml($xmlElement->user);
         $token->setUser($userObject);
     }
     if (!empty($xmlElement->consumer)) {
         $consumerObject = Consumer::parseFromXml($xmlElement->consumer);
         $token->setConsumer($consumerObject);
     }
     return $token;
 }