/**
  * @test
  */
 public function canGetAllByType()
 {
     $artifactType = new ArtifactType();
     $artifactType->setName('topseller');
     $validator = $this->getMock('\\Symfony\\Component\\Validator\\Validator', array('validate'), array(), '', FALSE);
     $storageBackend = $this->getMock('\\Searchperience\\Api\\Client\\System\\Storage\\RestArtifactBackend', array('getAllByType'));
     $storageBackend->expects($this->once())->method('getAllByType')->with($artifactType)->will($this->returnValue(new ArtifactCollection()));
     $this->repository->injectStorageBackend($storageBackend);
     $this->repository->setEntityCollectionName('\\Searchperience\\Api\\Client\\Domain\\Insight\\ArtifactCollection');
     $this->repository->injectValidator($validator);
     $this->repository->getAllByType($artifactType);
 }
 /**
  * @param mixed $jsonData
  * @return array|ArtifactTypeCollection
  */
 protected function buildFromJson($jsonData)
 {
     $artifactTypeCollection = new ArtifactTypeCollection();
     $types = $jsonData["data"];
     foreach ($types as $type) {
         $artifactType = new ArtifactType();
         if (isset($type["name"])) {
             $artifactType->setName($type["name"]);
         }
         $artifactTypeCollection[] = $artifactType;
     }
     return $artifactTypeCollection;
 }
 /**
  * @test
  */
 public function canGetAllArtifactType()
 {
     $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/artifact_types.json')));
     $restClient->addSubscriber($mock);
     $this->artifactTypeBackend->injectRestClient($restClient);
     $expectedArtifactTypeCollection = new ArtifactTypeCollection();
     $artifactType1 = new ArtifactType();
     $artifactType1->setName("topseller");
     $expectedArtifactTypeCollection->append($artifactType1);
     $artifactType2 = new ArtifactType();
     $artifactType2->setName("recommendation");
     $expectedArtifactTypeCollection->append($artifactType2);
     $actualArtifactTypeCollection = $this->artifactTypeBackend->getAll();
     $this->assertEquals($expectedArtifactTypeCollection, $actualArtifactTypeCollection);
 }
 /**
  * @test
  */
 public function canGetAllByType()
 {
     $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/artifacts.json')));
     $restClient->addSubscriber($mock);
     $this->artifactBackend->injectRestClient($restClient);
     $expectedArtifactCollection = new ArtifactCollection();
     $expectedArtifact1 = new GenericArtifact();
     $expectedArtifact1->setId("1");
     $expectedArtifact1->setTypeName("topseller");
     $expectedArtifactCollection->append($expectedArtifact1);
     $expectedArtifact2 = new GenericArtifact();
     $expectedArtifact2->setId("2");
     $expectedArtifact2->setTypeName("topseller");
     $expectedArtifactCollection->append($expectedArtifact2);
     $artifactType = new ArtifactType();
     $artifactType->setName("topseller");
     $actualArtifacts = $this->artifactBackend->getAllByType($artifactType);
     $this->assertEquals($expectedArtifactCollection, $actualArtifacts);
 }
 /**
  * @test
  */
 public function verifyGetterAndSetter()
 {
     $this->entity->setName('topseller');
     $this->assertEquals($this->entity->getName(), 'topseller');
 }