Skip to content

Commit

Permalink
More work being done on finishing the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 6, 2014
1 parent 19003d5 commit 9ede605
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 13 deletions.
44 changes: 35 additions & 9 deletions test/Tmdb/Tests/Factory/TvEpisodeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
class TvEpisodeFactoryTest extends TestCase
{
/**
* @test
* @var Episode
*/
public function shouldConstructTvEpisode()
private $episode;

public function setUp()
{
/**
* @var TvEpisodeFactory $factory
Expand All @@ -31,16 +33,22 @@ public function shouldConstructTvEpisode()
/**
* @var Episode $episode
*/
$episode = $factory->create($data);
$this->episode = $factory->create($data);
}

$this->assertInstanceOf('Tmdb\Model\Tv\Episode', $episode);
/**
* @test
*/
public function shouldConstructTvEpisode()
{
$this->assertInstanceOf('Tmdb\Model\Tv\Episode', $this->episode);

$this->assertInstanceOf('\DateTime', $episode->getAirDate());
$this->assertInstanceOf('\DateTime', $this->episode->getAirDate());

$this->assertInstanceOf('Tmdb\Model\Collection\Credits', $episode->getCredits());
$this->assertInstanceOf('Tmdb\Model\Tv\ExternalIds', $episode->getExternalIds());
$this->assertInstanceOf('Tmdb\Model\Collection\Images', $episode->getImages());
$this->assertInstanceOf('Tmdb\Model\Image\StillImage', $episode->getStill());
$this->assertInstanceOf('Tmdb\Model\Collection\Credits', $this->episode->getCredits());
$this->assertInstanceOf('Tmdb\Model\Tv\ExternalIds', $this->episode->getExternalIds());
$this->assertInstanceOf('Tmdb\Model\Collection\Images', $this->episode->getImages());
$this->assertInstanceOf('Tmdb\Model\Image\StillImage', $this->episode->getStill());
}

/**
Expand All @@ -64,6 +72,24 @@ public function shouldBeAbleToSetFactories()
$this->assertInstanceOf('stdClass', $factory->getImageFactory());
}

/**
* @test
*/
public function shouldBeFunctional()
{
$this->assertEquals(new \DateTime('2009-03-08'), $this->episode->getAirDate());
$this->assertEquals(1, $this->episode->getEpisodeNumber());
$this->assertEquals('Seven Thirty-Seven', $this->episode->getName());
$this->assertEquals('Walt and Jesse try to figure a way out of their partnership with Tuco. Hank tries to mend the fences between Marie and Skyler.', $this->episode->getOverview());
$this->assertEquals(62092, $this->episode->getId());
$this->assertEquals(null, $this->episode->getProductionCode());
$this->assertEquals(2, $this->episode->getSeasonNumber());
$this->assertEquals('/bwgioLAgihPCUK21rLWocDaDM3g.jpg', $this->episode->getStillPath());
$this->assertEquals(0, $this->episode->getVoteAverage());
$this->assertEquals(0, $this->episode->getVoteCount());

}

protected function getFactoryClass()
{
return 'Tmdb\Factory\TvEpisodeFactory';
Expand Down
43 changes: 43 additions & 0 deletions test/Tmdb/Tests/Model/Movie/ReleaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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\Model\Movie;

use Tmdb\Common\ObjectHydrator;
use Tmdb\Model\Movie\Release;
use Tmdb\Tests\Model\TestCase;

class ReleaseTest extends TestCase
{
/**
* @test
*/
public function shouldBeFunctional()
{
$data = array(
'iso_3166_1' => 'US',
'certification' => 'R',
'release_date' => '1999-10-15',
);

$hydrator = new ObjectHydrator();

/**
* @var Release $object
*/
$object = $hydrator->hydrate(new Release(), $data);

$this->assertEquals('US', $object->getIso31661());
$this->assertEquals('R', $object->getCertification());
$this->assertEquals(new \DateTime('1999-10-15'), $object->getReleaseDate());
}
}
37 changes: 35 additions & 2 deletions test/Tmdb/Tests/Model/MovieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
namespace Tmdb\Tests\Model;

use Tmdb\Model\Collection\Credits;
use Tmdb\Model\Collection\ResultCollection;
use Tmdb\Model\Movie;

class MovieTest extends TestCase
Expand All @@ -21,10 +23,10 @@ class MovieTest extends TestCase
*/
public function shouldConstructMovie()
{
$person = new Movie();
$movie = new Movie();

$this->assertInstancesOf(
$person,
$movie,
array(
/** Constructor */
'getGenres' => 'Tmdb\Model\Collection\Genres',
Expand All @@ -44,4 +46,35 @@ public function shouldConstructMovie()
)
);
}

/**
* @test
*/
public function shouldAllowOverridingDefaultCollectionObjects()
{
$movie = new Movie();

$class = new ResultCollection();
$className = get_class($class);

$movie->setChanges($class);
$movie->setProductionCompanies($class);
$movie->setProductionCountries($class);
$movie->setSpokenLanguages($class);
$movie->setCredits(new Credits());
$movie->setLists($class);

$this->assertInstancesOf(
$movie,
array(
/** Constructor */
'getChanges' => $className,
'getProductionCompanies' => $className,
'getProductionCountries' => $className,
'getSpokenLanguages' => $className,
'getCredits' => 'Tmdb\Model\Collection\Credits',
'getLists' => $className,
)
);
}
}
24 changes: 24 additions & 0 deletions test/Tmdb/Tests/Model/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
namespace Tmdb\Tests\Model;

use Tmdb\Model\Common\GenericCollection;
use Tmdb\Model\Person;

class GenreTest extends TestCase
Expand Down Expand Up @@ -52,4 +53,27 @@ public function shouldBeAbleToReplaceCollections()
$this->assertInstanceOf('stdClass', $factory->getMovieCredits());
$this->assertInstanceOf('stdClass', $factory->getTvCredits());
}

/**
* @test
*/
public function shouldAllowOverridingDefaultCollectionObjects()
{
$movie = new Person();

$class = new GenericCollection();
$className = get_class($class);

$movie->setChanges($class);
$movie->setCredits($class);

$this->assertInstancesOf(
$movie,
array(
/** Constructor */
'getChanges' => $className,
'getCredits' => $className
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Tmdb\Tests\Model\TestCase;
use Tmdb\Model\Tv\Episode;

class TvEpisodeTest extends TestCase
class EpisodeTest extends TestCase
{
/**
* @test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Tmdb\Tests\Model\TestCase;
use Tmdb\Model\Tv\Season;

class TvSeasonTest extends TestCase
class SeasonTest extends TestCase
{
/**
* @test
Expand Down

0 comments on commit 9ede605

Please sign in to comment.