forked from php-tmdb/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f38feb6
commit c9c8e64
Showing
9 changed files
with
285 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Tests\Factory; | ||
|
||
class ImageFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldConstructGenres() | ||
{ | ||
$this->assertEquals(true,true); | ||
} | ||
|
||
protected function getFactoryClass() | ||
{ | ||
return 'Tmdb\Factory\ImageFactory'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Tests\Model\Common; | ||
|
||
use Tmdb\Model\Collection\Keywords; | ||
use Tmdb\Model\Movie\Keyword; | ||
use Tmdb\Tests\Model\TestCase; | ||
|
||
class KeywordsTest extends TestCase | ||
{ | ||
/** | ||
* @var Keywords | ||
*/ | ||
private $collection; | ||
|
||
private $keywords = array( | ||
array('id' => 1, 'name' => 'dark'), | ||
array('id' => 2, 'name' => 'light') | ||
); | ||
|
||
public function setUp() | ||
{ | ||
$this->collection = new Keywords(); | ||
|
||
foreach($this->keywords as $keyword) { | ||
$object = $this->hydrate(new Keyword(), $keyword); | ||
|
||
$this->collection->addKeyword($object); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAndSet() | ||
{ | ||
$this->assertEquals(count($this->keywords), count($this->collection->getKeywords())); | ||
|
||
$this->assertEquals('dark', $this->collection->getKeyword(1)->getName()); | ||
$this->assertEquals(null, $this->collection->getKeyword(3)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Tests\Model\Common; | ||
|
||
use Tmdb\Model\Collection\People; | ||
use Tmdb\Model\Person; | ||
use Tmdb\Tests\Model\TestCase; | ||
|
||
class PeopleTest extends TestCase | ||
{ | ||
/** | ||
* @var People | ||
*/ | ||
private $collection; | ||
|
||
private $people = array( | ||
array('id' => 1, 'name' => 'james blunt'), | ||
array('id' => 2, 'name' => 'afrojack') | ||
); | ||
|
||
public function setUp() | ||
{ | ||
$this->collection = new People(); | ||
|
||
foreach($this->people as $keyword) { | ||
$object = $this->hydrate(new Person(), $keyword); | ||
|
||
$this->collection->addPerson($object); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAndSet() | ||
{ | ||
$this->assertEquals(count($this->people), count($this->collection->getPeople())); | ||
|
||
$this->assertEquals('james blunt', $this->collection->getPerson(1)->getName()); | ||
$this->assertEquals(null, $this->collection->getPerson(3)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* This file is part of the Tmdb PHP API created by Michael Roterman. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Tmdb | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, Michael Roterman | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Tests\Model; | ||
|
||
use Tmdb\Factory\ImageFactory; | ||
use Tmdb\Model\Collection\Images; | ||
use Tmdb\Model\Image; | ||
|
||
class ImageTest extends TestCase | ||
{ | ||
/** | ||
* @var Images | ||
*/ | ||
private $collection; | ||
|
||
private $images = array( | ||
array( | ||
'file_path' => '/abc.jpg', | ||
'width' => 1000, | ||
'height' => 750, | ||
'iso_639_1' => 'en', | ||
'aspect_ratio' => 0.75, | ||
'vote_average' => 2.25, | ||
'vote_count' => 25 | ||
), | ||
); | ||
|
||
public function setUp() | ||
{ | ||
$this->collection = new Images(); | ||
|
||
foreach($this->images as $image) { | ||
$factory = new ImageFactory(); | ||
$object = $factory->create($image); | ||
|
||
$this->collection->addImage($object); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAndSet() | ||
{ | ||
$this->assertEquals(count($this->images), count($this->collection->getImages())); | ||
|
||
/** | ||
* @var Image $subject | ||
*/ | ||
$subject = array_pop($this->collection->toArray()); | ||
|
||
$this->assertEquals('/abc.jpg', $subject->getFilePath()); | ||
$this->assertEquals(1000, $subject->getWidth()); | ||
$this->assertEquals(750, $subject->getHeight()); | ||
$this->assertEquals('en', $subject->getIso6391()); | ||
$this->assertEquals(0.75, $subject->getAspectRatio()); | ||
$this->assertEquals(2.25, $subject->getVoteAverage()); | ||
$this->assertEquals(25, $subject->getVoteCount()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldReturnCorrectTypes() | ||
{ | ||
$this->assertEquals('poster', Image::getTypeFromCollectionName('posters')); | ||
$this->assertEquals('backdrop', Image::getTypeFromCollectionName('backdrops')); | ||
$this->assertEquals('profile', Image::getTypeFromCollectionName('profiles')); | ||
$this->assertEquals('logo', Image::getTypeFromCollectionName('logos')); | ||
$this->assertEquals('still', Image::getTypeFromCollectionName('stills')); | ||
$this->assertEquals(null, Image::getTypeFromCollectionName('sheeps')); | ||
} | ||
} |