public function testLanguage() { $actLang = 'Japanese'; $actor = new Actor(); $actor->setLanguage($actLang); $this->assertEquals($actLang, $actor->getActorLanguage()); }
private static function parseCharacters(Crawler $item) { $cast = new Cast(); if (preg_match('/character\\/(.*?)\\/.*$/', $item->filter('a')->attr('href'), $characterIds)) { $cast->setId($characterIds[1]); } $cast->setName($item->filter('a')->eq(1)->text()); $imageUrl = $item->filter('img')->attr('data-src'); $imageUrl = preg_replace('/\\/r\\/.*?x.*?\\//', '/', $imageUrl); $imageUrl = preg_replace('/\\?s=.*$/', '', $imageUrl); $cast->setImage($imageUrl); $cast->setRole($item->filter('small')->text()); foreach ($item->filter('table[class="space_table"] tr') as $actorItem) { $actor = new Actor(); $crawler = new Crawler($actorItem); if ($crawler->filter('td')->count() > 1) { if (preg_match('/people\\/(.*?)\\/.*$/', $crawler->filter('a')->attr('href'), $actorIds)) { $actor->setId($actorIds[1]); } $actor->setName($crawler->filter('a')->text()); $actor->setLanguage($crawler->filter('small')->last()->text()); $imageUrl = $item->filter('img')->last()->attr('data-src'); $imageUrl = preg_replace('/\\/r\\/.*?x.*?\\//', '/', $imageUrl); $imageUrl = preg_replace('/\\?s=.*$/', '', $imageUrl); $actor->setImage($imageUrl); $cast->setActors($actor); } } return $cast; }
public function testActors() { $actor = new Actor(); $actor->setId(1); $actor->setName('Taro Yamada'); $actor->setLanguage('Japanese'); $actor->setImage('http://www.example.com/image.jpg'); $cast = new Cast(); $cast->setActors($actor); $actors = $cast->getActors(); $this->assertEquals($actor, $actors[0]); }