diff --git a/lib/Tmdb/Factory/AbstractFactory.php b/lib/Tmdb/Factory/AbstractFactory.php index c583f2f1..b57d8a57 100644 --- a/lib/Tmdb/Factory/AbstractFactory.php +++ b/lib/Tmdb/Factory/AbstractFactory.php @@ -61,7 +61,7 @@ protected function createGenericCollection(array $data = array(), $class) * * @param array $data * @param string $method - * @return GenericCollection + * @return ResultCollection */ public function createResultCollection(array $data = array(), $method = 'create') { diff --git a/lib/Tmdb/Factory/MovieFactory.php b/lib/Tmdb/Factory/MovieFactory.php index 98aa4d6e..9c992b04 100644 --- a/lib/Tmdb/Factory/MovieFactory.php +++ b/lib/Tmdb/Factory/MovieFactory.php @@ -149,7 +149,7 @@ public function create(array $data = array()) } if (array_key_exists('reviews', $data)) { - $movie->setReviews($this->getReviewFactory()->createCollection($data['reviews'])); + $movie->setReviews($this->getReviewFactory()->createResultCollection($data['reviews'])); } if (array_key_exists('lists', $data)) { diff --git a/lib/Tmdb/Model/Review.php b/lib/Tmdb/Model/Review.php index fc6de85e..8c790fff 100644 --- a/lib/Tmdb/Model/Review.php +++ b/lib/Tmdb/Model/Review.php @@ -17,12 +17,20 @@ class Review extends AbstractModel { private $id; private $author; private $content; + private $iso6391; + private $mediaId; + private $mediaTitle; + private $mediaType; private $url; public static $_properties = array( 'id', 'author', 'content', + 'iso_639_1', + 'media_id', + 'media_title', + 'media_type', 'url' ); @@ -80,6 +88,78 @@ public function getId() return $this->id; } + /** + * @param mixed $iso6391 + * @return $this + */ + public function setIso6391($iso6391) + { + $this->iso6391 = $iso6391; + return $this; + } + + /** + * @return mixed + */ + public function getIso6391() + { + return $this->iso6391; + } + + /** + * @param mixed $mediaId + * @return $this + */ + public function setMediaId($mediaId) + { + $this->mediaId = $mediaId; + return $this; + } + + /** + * @return mixed + */ + public function getMediaId() + { + return $this->mediaId; + } + + /** + * @param mixed $mediaTitle + * @return $this + */ + public function setMediaTitle($mediaTitle) + { + $this->mediaTitle = $mediaTitle; + return $this; + } + + /** + * @return mixed + */ + public function getMediaTitle() + { + return $this->mediaTitle; + } + + /** + * @param mixed $mediaType + * @return $this + */ + public function setMediaType($mediaType) + { + $this->mediaType = $mediaType; + return $this; + } + + /** + * @return mixed + */ + public function getMediaType() + { + return $this->mediaType; + } + /** * @param mixed $url * @return $this diff --git a/test/Tmdb/Tests/Factory/ReviewFactoryTest.php b/test/Tmdb/Tests/Factory/ReviewFactoryTest.php new file mode 100644 index 00000000..7368fb8d --- /dev/null +++ b/test/Tmdb/Tests/Factory/ReviewFactoryTest.php @@ -0,0 +1,59 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +namespace Tmdb\Tests\Factory; + +use Tmdb\Factory\ReviewFactory; +use Tmdb\Model\Review; + +class ReviewFactoryTest extends TestCase +{ + private $data; + + public function setUp() + { + $this->data = $this->loadByFile('reviews/get.json'); + } + + /** + * @test + */ + public function shouldConstructReview() + { + /** + * @var ReviewFactory $factory + */ + $factory = $this->getFactory(); + + /** + * @var Review $review + */ + $review = $factory->create($this->data); + + $review->setContent('content-test'); + + $this->assertInstanceOf('Tmdb\Model\Review', $review); + $this->assertEquals('5013bc76760ee372cb00253e', $review->getId()); + $this->assertEquals('Chris', $review->getAuthor()); + $this->assertEquals('content-test', $review->getContent()); + $this->assertEquals('en', $review->getIso6391()); + $this->assertEquals(49026, $review->getMediaId()); + $this->assertEquals('The Dark Knight Rises', $review->getMediaTitle()); + $this->assertEquals('Movie', $review->getMediaType()); + $this->assertEquals('http://j.mp/P18dg1', $review->getUrl()); + } + + protected function getFactoryClass() + { + return 'Tmdb\Factory\ReviewFactory'; + } +} \ No newline at end of file diff --git a/test/Tmdb/Tests/Resources/reviews/get.json b/test/Tmdb/Tests/Resources/reviews/get.json new file mode 100644 index 00000000..7c5dca2e --- /dev/null +++ b/test/Tmdb/Tests/Resources/reviews/get.json @@ -0,0 +1,10 @@ +{ + "id": "5013bc76760ee372cb00253e", + "author": "Chris", + "content": "I personally thought this film is on par if not better than the Dark Knight.\r\n\r\nWhilst some think the film is too long for the story I didn't find this. The length of the film is longer than some (but doesn't feel it), I liked that the film took it's time rather than shoving more elements in it - I think this contributed to the dramatic ending (much like a classical piece of music will be relaxed and calm before the final crescendo).\r\n\r\nAt the end of the day whether you like this film will boil down to if you like films Christopher Nolan has directed and/or you like the Christopher Nolan Batman series so far.\r\n\r\nStupendously good film in my opinion.", + "iso_639_1": "en", + "media_id": 49026, + "media_title": "The Dark Knight Rises", + "media_type": "Movie", + "url": "http://j.mp/P18dg1" +} \ No newline at end of file