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';