/**
  * @test
  * @expectedException \Searchperience\Common\Exception\InvalidArgumentException
  */
 public function canNotSetInvalidMatchingType()
 {
     $this->synonym->setType('Nothing');
 }
 /**
  * @test
  */
 public function canDeleteBySynonym()
 {
     //$this->markTestIncomplete('Process error');
     $this->synonymBackend = $this->getMock('\\Searchperience\\Api\\Client\\System\\Storage\\RestSynonymBackend', array('getDeleteResponseFromEndpoint'));
     $this->synonymBackend->injectDateTimeService(new \Searchperience\Api\Client\System\DateTime\DateTimeService());
     $restClient = new \Guzzle\Http\Client('http://api.searchperience.com/');
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse(new \Guzzle\Http\Message\Response(201));
     $restClient->addSubscriber($mock);
     $this->synonymBackend->injectRestClient($restClient);
     $synonym = new Synonym();
     $synonym->setSynonyms('foo');
     $synonym->setTagName('one');
     $this->synonymBackend->expects($this->once())->method('getDeleteResponseFromEndpoint')->with('/one', $synonym)->will($this->returnValue($this->getMock('\\Guzzle\\Http\\Message\\Response', array(), array(), '', false)));
     $this->synonymBackend->delete('one', $synonym);
 }
 /**
  * @param \SimpleXMLElement $xml
  * @return \Searchperience\Api\Client\Domain\Synonym\SynonymCollection
  */
 protected function buildSynonymsFromXml(\SimpleXMLElement $xml)
 {
     $synonymCollection = new SynonymCollection();
     if ($xml->totalCount instanceof \SimpleXMLElement) {
         $synonymCollection->setTotalCount((int) $xml->totalCount->__toString());
     }
     $synonyms = $xml->xpath('synonym');
     foreach ($synonyms as $synonym) {
         $synonymAttributeArray = (array) $synonym->attributes();
         $synonymObject = new Synonym();
         $synonymObject->__setProperty('synonyms', (string) $synonym->synonyms);
         $synonymObject->__setProperty('tagName', (string) $synonymAttributeArray['@attributes']['tag']);
         $synonymObject->__setProperty('mappedWords', (string) $synonym->mappedWords);
         $synonymCollection->append($synonymObject);
     }
     return $synonymCollection;
 }