/** * @test * @group admin */ public function verifyAdminSearchHasProperties() { $this->adminSearch->__setProperty("title", "test title"); $this->adminSearch->__setProperty("description", "test description"); $this->adminSearch->__setProperty("url", "http://www.your.domain"); $this->assertEquals($this->adminSearch->getTitle(), "test title"); $this->assertEquals($this->adminSearch->getDescription(), "test description"); $this->assertEquals($this->adminSearch->getUrl(), "http://www.your.domain"); }
/** * @param \SimpleXMLElement $xml * @return array|AdminSearchCollection */ protected function buildFromXml(\SimpleXMLElement $xml) { $adminSearchCollection = new AdminSearchCollection(); if ($xml->totalCount instanceof \SimpleXMLElement) { $adminSearchCollection->setTotalCount((int) $xml->totalCount->__toString()); } $adminsearches = $xml->xpath('adminsearch'); foreach ($adminsearches as $adminsearch) { $adminsearchAttributeArray = (array) $adminsearch->attributes(); $adminSearchObject = new AdminSearch(); $adminSearchObject->__setProperty('id', (string) $adminsearchAttributeArray['@attributes']['id']); $adminSearchObject->__setProperty('title', (string) $adminsearch->title); $adminSearchObject->__setProperty('description', (string) $adminsearch->description); $adminSearchObject->__setProperty('url', (string) $adminsearch->url); $adminSearchCollection[] = $adminSearchObject; $adminSearchObject->afterReconstitution(); } return $adminSearchCollection; }
/** * @test */ public function canGetAllAdminSearchCollection() { $restClient = new \Guzzle\Http\Client('http://api.searchperience.me/qvc/'); $mock = new \Guzzle\Plugin\Mock\MockPlugin(); $mock->addResponse(new \Guzzle\Http\Message\Response(201, NULL, $this->getFixtureContent('Api/Client/System/Storage/Fixture/adminsearch_collection.xml'))); $restClient->addSubscriber($mock); $this->adminSearchBackend->injectRestClient($restClient); $expectedAdminSearchCollection = new AdminSearchCollection(); $expectedAdminSearch1 = new AdminSearch(); $expectedAdminSearch1->__setProperty("id", "1"); $expectedAdminSearch1->__setProperty("title", "some endpoint"); $expectedAdminSearch1->__setProperty("description", "some endpoint"); $expectedAdminSearch1->__setProperty("url", "http://www.dummy.url/api/"); $expectedAdminSearchCollection->append($expectedAdminSearch1); $expectedAdminSearch2 = new AdminSearch(); $expectedAdminSearch2->__setProperty("id", "2"); $expectedAdminSearch2->__setProperty("title", "some endpoint 2"); $expectedAdminSearch2->__setProperty("description", "some endpoint 2"); $expectedAdminSearch2->__setProperty("url", "http://www.dummy.url/api/v2"); $expectedAdminSearchCollection->append($expectedAdminSearch2); $actualAdminSearchCollection = $this->adminSearchBackend->getAll(); $this->assertEquals($expectedAdminSearchCollection, $actualAdminSearchCollection); }