From eb2a91adf7b3fc91fdbce3a2baf7c203d351209a Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sat, 8 Feb 2014 15:59:08 +0100 Subject: [PATCH] AbstractMember coverage --- lib/Tmdb/Model/Person/AbstractMember.php | 10 ++++++++++ test/Tmdb/Tests/Factory/MovieFactoryTest.php | 21 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/Tmdb/Model/Person/AbstractMember.php b/lib/Tmdb/Model/Person/AbstractMember.php index 05ea915e..7eb43b81 100644 --- a/lib/Tmdb/Model/Person/AbstractMember.php +++ b/lib/Tmdb/Model/Person/AbstractMember.php @@ -114,4 +114,14 @@ public function getProfile() { return $this->profile; } + + /** + * Assert if there is an profile image object + * + * @return bool + */ + public function hasProfileImage() + { + return $this->profile instanceof Image; + } } diff --git a/test/Tmdb/Tests/Factory/MovieFactoryTest.php b/test/Tmdb/Tests/Factory/MovieFactoryTest.php index 17add803..d25ac5c7 100644 --- a/test/Tmdb/Tests/Factory/MovieFactoryTest.php +++ b/test/Tmdb/Tests/Factory/MovieFactoryTest.php @@ -14,6 +14,7 @@ use Tmdb\Factory\MovieFactory; use Tmdb\Model\Movie; +use Tmdb\Model\Person\CastMember; class MovieFactoryTest extends TestCase { @@ -122,6 +123,26 @@ public function shouldBeAbleToDissectResults() $this->assertEquals(2, count($collection)); } + /** + * @test + */ + public function shouldGetProfileImages() + { + $cast = $this->movie->getCredits()->getCast(); + + /** + * @var CastMember $c + */ + foreach($cast as $c) { + if ($c->hasProfileImage()) { + $filePath = $c->getProfile()->getFilePath(); + $this->assertEquals(false, empty($filePath)); + }else{ + $this->assertEquals(null, $c->getProfile()); + } + } + } + protected function getFactoryClass() { return 'Tmdb\Factory\MovieFactory';