From 19003d5e30dfc84bccdacebd4f6241119f7f492b Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Thu, 6 Feb 2014 00:28:44 +0100 Subject: [PATCH] Removing unnecassary classes related to people --- lib/Tmdb/Factory/TvEpisodeFactory.php | 4 +- lib/Tmdb/Factory/TvFactory.php | 6 +- lib/Tmdb/Factory/TvSeasonFactory.php | 4 +- lib/Tmdb/Model/Person/AbstractMember.php | 39 ++++----- lib/Tmdb/Model/Person/CastMember.php | 11 +++ lib/Tmdb/Model/Person/CrewMember.php | 7 ++ lib/Tmdb/Model/Tv/Person/CastMember.php | 85 ------------------- lib/Tmdb/Model/Tv/Person/CrewMember.php | 18 ---- .../Tests/Model/Person/CastMemberTest.php | 46 ++++++++++ .../Tests/Model/Person/CrewMemberTest.php | 44 ++++++++++ test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php | 46 ++++++++++ test/Tmdb/Tests/Model/Tv/NetworkTest.php | 38 +++++++++ 12 files changed, 215 insertions(+), 133 deletions(-) delete mode 100644 lib/Tmdb/Model/Tv/Person/CastMember.php delete mode 100644 lib/Tmdb/Model/Tv/Person/CrewMember.php create mode 100644 test/Tmdb/Tests/Model/Person/CastMemberTest.php create mode 100644 test/Tmdb/Tests/Model/Person/CrewMemberTest.php create mode 100644 test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php create mode 100644 test/Tmdb/Tests/Model/Tv/NetworkTest.php diff --git a/lib/Tmdb/Factory/TvEpisodeFactory.php b/lib/Tmdb/Factory/TvEpisodeFactory.php index a97b772e..948fb82a 100644 --- a/lib/Tmdb/Factory/TvEpisodeFactory.php +++ b/lib/Tmdb/Factory/TvEpisodeFactory.php @@ -15,9 +15,9 @@ use Tmdb\Factory\People\CastFactory; use Tmdb\Factory\People\CrewFactory; use Tmdb\Model\Common\GenericCollection; +use Tmdb\Model\Person\CastMember; +use Tmdb\Model\Person\CrewMember; use Tmdb\Model\Tv\ExternalIds; -use Tmdb\Model\Tv\Person\CastMember; -use Tmdb\Model\Tv\Person\CrewMember; use Tmdb\Model\Tv\Episode; class TvEpisodeFactory extends AbstractFactory { diff --git a/lib/Tmdb/Factory/TvFactory.php b/lib/Tmdb/Factory/TvFactory.php index 7627f2b9..1e16c0fe 100644 --- a/lib/Tmdb/Factory/TvFactory.php +++ b/lib/Tmdb/Factory/TvFactory.php @@ -16,6 +16,8 @@ use Tmdb\Factory\People\CrewFactory; use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Common\Translation; +use Tmdb\Model\Person\CastMember; +use Tmdb\Model\Person\CrewMember; use Tmdb\Model\Tv\ExternalIds; use Tmdb\Model\Tv; @@ -70,11 +72,11 @@ public function create(array $data = array()) if (array_key_exists('credits', $data)) { if (array_key_exists('cast', $data['credits'])) { - $tvShow->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new Tv\Person\CastMember())); + $tvShow->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember())); } if (array_key_exists('crew', $data['credits'])) { - $tvShow->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new Tv\Person\CrewMember())); + $tvShow->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember())); } } diff --git a/lib/Tmdb/Factory/TvSeasonFactory.php b/lib/Tmdb/Factory/TvSeasonFactory.php index 4d070610..0483c25d 100644 --- a/lib/Tmdb/Factory/TvSeasonFactory.php +++ b/lib/Tmdb/Factory/TvSeasonFactory.php @@ -15,9 +15,9 @@ use Tmdb\Factory\People\CastFactory; use Tmdb\Factory\People\CrewFactory; use Tmdb\Model\Common\GenericCollection; +use Tmdb\Model\Person\CastMember; +use Tmdb\Model\Person\CrewMember; use Tmdb\Model\Tv\ExternalIds; -use Tmdb\Model\Tv\Person\CastMember; -use Tmdb\Model\Tv\Person\CrewMember; use Tmdb\Model\Tv\Season; class TvSeasonFactory extends AbstractFactory { diff --git a/lib/Tmdb/Model/Person/AbstractMember.php b/lib/Tmdb/Model/Person/AbstractMember.php index 47a82b2e..05ea915e 100644 --- a/lib/Tmdb/Model/Person/AbstractMember.php +++ b/lib/Tmdb/Model/Person/AbstractMember.php @@ -17,20 +17,29 @@ abstract class AbstractMember extends AbstractModel { + /** + * @var int + */ private $id; + + /** + * @var string + */ private $name; + + /** + * @var string + */ private $profilePath; - private $order; /** - * @var Image + * @var Image\ProfileImage */ private $profile; public static $_properties = array( 'id', 'name', - 'order', 'profile_path' ); @@ -89,35 +98,17 @@ public function getProfilePath() } /** - * @param integer $order - * @return $this - */ - public function setOrder($order) - { - $this->order = $order; - return $this; - } - - /** - * @return integer - */ - public function getOrder() - { - return $this->order; - } - - /** - * @param Image $profile + * @param Image\ProfileImage $profile * @return $this */ - public function setProfile(Image $profile) + public function setProfile($profile = null) { $this->profile = $profile; return $this; } /** - * @return Image + * @return Image\ProfileImage|null */ public function getProfile() { diff --git a/lib/Tmdb/Model/Person/CastMember.php b/lib/Tmdb/Model/Person/CastMember.php index 3fbe33ab..eb2bf7ed 100644 --- a/lib/Tmdb/Model/Person/CastMember.php +++ b/lib/Tmdb/Model/Person/CastMember.php @@ -16,8 +16,19 @@ class CastMember extends AbstractMember implements PersonInterface { + /** + * @var string + */ private $character; + + /** + * @var int + */ private $order; + + /** + * @var mixed + */ private $castId; public static $_properties = array( diff --git a/lib/Tmdb/Model/Person/CrewMember.php b/lib/Tmdb/Model/Person/CrewMember.php index 8a08adf8..b97f7629 100644 --- a/lib/Tmdb/Model/Person/CrewMember.php +++ b/lib/Tmdb/Model/Person/CrewMember.php @@ -16,7 +16,14 @@ class CrewMember extends AbstractMember implements PersonInterface { + /** + * @var string + */ private $department; + + /** + * @var string + */ private $job; public static $_properties = array( diff --git a/lib/Tmdb/Model/Tv/Person/CastMember.php b/lib/Tmdb/Model/Tv/Person/CastMember.php deleted file mode 100644 index 0383f7f4..00000000 --- a/lib/Tmdb/Model/Tv/Person/CastMember.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright (c) 2013, Michael Roterman - * @version 0.0.1 - */ -namespace Tmdb\Model\Tv\Person; - -use Tmdb\Model\Person\AbstractMember; - -class CastMember extends AbstractMember { - - private $character; - private $order; - private $creditId; - - public static $_properties = array( - 'id', - 'credit_id', - 'name', - 'character', - 'order', - 'profile_path' - ); - - /** - * @param mixed $character - * @return $this - */ - public function setCharacter($character) - { - $this->character = $character; - return $this; - } - - /** - * @return mixed - */ - public function getCharacter() - { - return $this->character; - } - - /** - * @param mixed $order - * @return $this - */ - public function setOrder($order) - { - $this->order = (int) $order; - return $this; - } - - /** - * @return integer - */ - public function getOrder() - { - return $this->order; - } - - /** - * @param mixed $creditId - * @return $this - */ - public function setCreditId($creditId) - { - $this->creditId = $creditId; - return $this; - } - - /** - * @return mixed - */ - public function getCreditId() - { - return $this->creditId; - } -} diff --git a/lib/Tmdb/Model/Tv/Person/CrewMember.php b/lib/Tmdb/Model/Tv/Person/CrewMember.php deleted file mode 100644 index 2efabc46..00000000 --- a/lib/Tmdb/Model/Tv/Person/CrewMember.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @copyright (c) 2013, Michael Roterman - * @version 0.0.1 - */ -namespace Tmdb\Model\Tv\Person; - -use Tmdb\Model\Person\CrewMember as BaseCrewMember; - -class CrewMember extends BaseCrewMember { -} diff --git a/test/Tmdb/Tests/Model/Person/CastMemberTest.php b/test/Tmdb/Tests/Model/Person/CastMemberTest.php new file mode 100644 index 00000000..ab0d14d4 --- /dev/null +++ b/test/Tmdb/Tests/Model/Person/CastMemberTest.php @@ -0,0 +1,46 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Tests\Model\Person; + +use Tmdb\Common\ObjectHydrator; +use Tmdb\Model\Person\CastMember; +use Tmdb\Tests\Model\TestCase; + +class CastMemberTest extends TestCase +{ + /** + * @test + */ + public function shouldBeFunctional() + { + $data = array( + 'id' => 819, + 'name' => 'Edward Norton', + 'character' => 'The Narrator', + 'order' => 0, + 'cast_id' => 4, + 'profile_path' => '/588Hrov6wwM9WcU88nJHlw2iufN.jpg' + ); + + $hydrator = new ObjectHydrator(); + + $object = $hydrator->hydrate(new CastMember(), $data); + + $this->assertEquals(819, $object->getId()); + $this->assertEquals('Edward Norton', $object->getName()); + $this->assertEquals('The Narrator', $object->getCharacter()); + $this->assertEquals(0, $object->getOrder()); + $this->assertEquals(4, $object->getCastId()); + $this->assertEquals('/588Hrov6wwM9WcU88nJHlw2iufN.jpg', $object->getProfilePath()); + } +} diff --git a/test/Tmdb/Tests/Model/Person/CrewMemberTest.php b/test/Tmdb/Tests/Model/Person/CrewMemberTest.php new file mode 100644 index 00000000..86f1eb4d --- /dev/null +++ b/test/Tmdb/Tests/Model/Person/CrewMemberTest.php @@ -0,0 +1,44 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Tests\Model\Person; + +use Tmdb\Common\ObjectHydrator; +use Tmdb\Model\Person\CrewMember; +use Tmdb\Tests\Model\TestCase; + +class CrewMemberTest extends TestCase +{ + /** + * @test + */ + public function shouldBeFunctional() + { + $data = array( + 'id' => 7477, + 'name' => 'John King', + 'department' => 'Sound', + 'job' => 'Original Music Composer', + 'profile_path' => null + ); + + $hydrator = new ObjectHydrator(); + + $object = $hydrator->hydrate(new CrewMember(), $data); + + $this->assertEquals(7477, $object->getId()); + $this->assertEquals('John King', $object->getName()); + $this->assertEquals('Sound', $object->getDepartment()); + $this->assertEquals('Original Music Composer', $object->getJob()); + $this->assertEquals(null, $object->getProfilePath()); + } +} diff --git a/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php b/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php new file mode 100644 index 00000000..6dcb2888 --- /dev/null +++ b/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php @@ -0,0 +1,46 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Tests\Model\Tv; + +use Tmdb\Common\ObjectHydrator; +use Tmdb\Model\Tv\ExternalIds; +use Tmdb\Tests\Model\TestCase; + +class ExternalIdsTest extends TestCase +{ + /** + * @test + */ + public function shouldBeFunctional() + { + $data = array( + 'imdb_id' => 'tt0903747', + 'freebase_id' => '/en/breaking_bad', + 'freebase_mid' => '/m/03d34x8', + 'id' => 1396, + 'tvdb_id' => 81189, + 'tvrage_id' => 18164, + ); + + $hydrator = new ObjectHydrator(); + + $object = $hydrator->hydrate(new ExternalIds(), $data); + + $this->assertEquals('tt0903747', $object->getImdbId()); + $this->assertEquals('/en/breaking_bad', $object->getFreebaseId()); + $this->assertEquals('/m/03d34x8', $object->getFreebaseMid()); + $this->assertEquals(1396, $object->getId()); + $this->assertEquals(81189, $object->getTvdbId()); + $this->assertEquals(18164, $object->getTvrageId()); + } +} diff --git a/test/Tmdb/Tests/Model/Tv/NetworkTest.php b/test/Tmdb/Tests/Model/Tv/NetworkTest.php new file mode 100644 index 00000000..0a7c3c1f --- /dev/null +++ b/test/Tmdb/Tests/Model/Tv/NetworkTest.php @@ -0,0 +1,38 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Tests\Model\Tv; + +use Tmdb\Common\ObjectHydrator; +use Tmdb\Model\Tv\Network; +use Tmdb\Tests\Model\TestCase; + +class NetworkTest extends TestCase +{ + /** + * @test + */ + public function shouldBeFunctional() + { + $data = array( + 'id' => 1, + 'name' => 'name', + ); + + $hydrator = new ObjectHydrator(); + + $object = $hydrator->hydrate(new Network(), $data); + + $this->assertEquals(1, $object->getId()); + $this->assertEquals('name', $object->getName()); + } +}