Skip to content

Commit

Permalink
Adding MovieFactoryTest, and fixing the base TestCase to always retur…
Browse files Browse the repository at this point in the history
…n assoc arrays.
  • Loading branch information
wtfzdotnet committed Jan 29, 2014
1 parent 5f37923 commit 04dc350
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Factory/CompanyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CompanyFactoryTest extends TestCase
public function shouldConstructCompany()
{
$factory = $this->getFactory();
$data = (array) $this->loadByFile('company/get.json');
$data = $this->loadByFile('company/get.json');

$company = $factory->create($data);

Expand Down
2 changes: 1 addition & 1 deletion test/Tmdb/Tests/Factory/GenreFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GenreFactoryTest extends TestCase
public function shouldConstructGenres()
{
$factory = $this->getFactory();
$data = (array) $this->loadByFile('genre/result.json');
$data = $this->loadByFile('genre/result.json');

$collection = $factory->createCollection($data['genres']);

Expand Down
61 changes: 61 additions & 0 deletions test/Tmdb/Tests/Factory/MovieFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @copyright (c) 2013, Michael Roterman
* @version 0.0.1
*/
namespace Tmdb\Tests\Factory;

use Tmdb\Factory\MovieFactory;

class MovieFactoryTest extends TestCase
{
const MOVIE_ID = 120;

/**
* @test
*/
public function shouldConstructMovie()
{
/**
* @var MovieFactory $factory
*/
$factory = $this->getFactory();
$data = $this->loadByFile('movie/all.json');

$movie = $factory->create($data);

$this->assertInstanceOf('Tmdb\Model\Movie', $movie);
}

/**
* @test
*/
public function shouldBeAbleToSetFactories()
{
$factory = new MovieFactory();

$class = new \stdClass();

$factory->setCastFactory($class);
$factory->setCrewFactory($class);
$factory->setGenreFactory($class);
$factory->setImageFactory($class);

$this->assertInstanceOf('stdClass', $factory->getCastFactory());
$this->assertInstanceOf('stdClass', $factory->getCrewFactory());
$this->assertInstanceOf('stdClass', $factory->getGenreFactory());
$this->assertInstanceOf('stdClass', $factory->getImageFactory());
}

protected function getFactoryClass()
{
return 'Tmdb\Factory\MovieFactory';
}
}
1 change: 1 addition & 0 deletions test/Tmdb/Tests/Resources/movie/all.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion test/Tmdb/Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected function loadByFile($file)
'test/Tmdb/Tests/Resources/',
$file
)
)
),
true
);
}
}

0 comments on commit 04dc350

Please sign in to comment.