Skip to content

Commit

Permalink
Updating SearchRepositoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 23, 2014
1 parent bcacadc commit c134d5d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Tmdb/Repository/SearchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// @todo
use Tmdb\Client;
use Tmdb\Exception\NotImplementedException;
use Tmdb\Exception\RuntimeException;
use Tmdb\Factory\CollectionFactory;
use Tmdb\Factory\CompanyFactory;
Expand Down Expand Up @@ -200,12 +201,12 @@ public function getApi()
}

/**
* Changes does not support a generic factory
* SearchRepository does not support a generic factory
*
* @throws RuntimeException
* @throws NotImplementedException
*/
public function getFactory(){
throw new RuntimeException();
throw new NotImplementedException('SearchRepository does not support a generic factory.');
}

/**
Expand Down
42 changes: 42 additions & 0 deletions test/Tmdb/Tests/Repository/SearchRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,48 @@ public function shouldSearchKeyword()
$repository->searchKeyword('alien', new KeywordSearchQuery());
}

/**
* @test
* @expectedException Tmdb\Exception\NotImplementedException
*/
public function shouldGetFactory()
{
/**
* @var SearchRepository $repository
*/
$repository = $this->getRepositoryWithMockedHttpClient();

$repository->getFactory();
}

/**
* @test
*/
public function shouldBeAbleToSetFactories()
{
/**
* @var SearchRepository $repository
*/
$repository = $this->getRepositoryWithMockedHttpClient();
$class = new \stdClass();

$repository->setMovieFactory($class);
$repository->setCollectionFactory($class);
$repository->setCompanyFactory($class);
$repository->setKeywordFactory($class);
$repository->setListItemFactory($class);
$repository->setPeopleFactory($class);
$repository->setTvFactory($class);

$this->assertInstanceOf('stdClass', $repository->getMovieFactory());
$this->assertInstanceOf('stdClass', $repository->getCollectionFactory());
$this->assertInstanceOf('stdClass', $repository->getCompanyFactory());
$this->assertInstanceOf('stdClass', $repository->getKeywordFactory());
$this->assertInstanceOf('stdClass', $repository->getListItemFactory());
$this->assertInstanceOf('stdClass', $repository->getPeopleFactory());
$this->assertInstanceOf('stdClass', $repository->getTvFactory());
}

protected function getApiClass()
{
return 'Tmdb\Api\Search';
Expand Down

0 comments on commit c134d5d

Please sign in to comment.