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
74c4bd7
commit 9add642
Showing
18 changed files
with
548 additions
and
73 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
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,25 @@ | ||
<?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 | ||
*/ | ||
class ApiTokenTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function testSetGet() | ||
{ | ||
$token = new \Tmdb\ApiToken(); | ||
$token->setApiToken('abcdefg'); | ||
|
||
$this->assertEquals('abcdefg', $token->getApiToken()); | ||
} | ||
} |
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,85 @@ | ||
<?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 | ||
*/ | ||
class ObjectHydratorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function canHydrateObject() | ||
{ | ||
$subject = \Tmdb\Common\ObjectHydrator::hydrate(new TestModel(), array( | ||
'id' => 15, | ||
'name' => 'Michael' | ||
)); | ||
|
||
$this->assertInstanceOf('TestModel', $subject); | ||
$this->assertEquals(15, $subject->getId()); | ||
$this->assertEquals('Michael', $subject->getName()); | ||
} | ||
|
||
/** | ||
* @expectedException \Tmdb\Exception\RuntimeException | ||
* @test | ||
*/ | ||
public function callingNonExistingMethodThrowsException() | ||
{ | ||
\Tmdb\Common\ObjectHydrator::hydrate(new FailingTestModel(), array('lastname' => 'Roterman')); | ||
} | ||
} | ||
|
||
class TestModel extends \Tmdb\Model\AbstractModel { | ||
private $id; | ||
private $name; | ||
|
||
static $_properties = array('id', 'name'); | ||
|
||
/** | ||
* @param mixed $id | ||
* @return $this | ||
*/ | ||
public function setId($id) | ||
{ | ||
$this->id = $id; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param mixed $name | ||
* @return $this | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
} | ||
|
||
class FailingTestModel extends \Tmdb\Model\AbstractModel { | ||
static $_properties = array('lastname'); | ||
} |
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,48 @@ | ||
<?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\Repository; | ||
|
||
class CollectionRepositoryTest extends TestCase | ||
{ | ||
const COLLECTION_ID = 120; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldLoadCollection() | ||
{ | ||
$repository = $this->getRepositoryWithMockedHttpClient(); | ||
|
||
$repository->load(self::COLLECTION_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetImages() | ||
{ | ||
$repository = $this->getRepositoryWithMockedHttpClient(); | ||
|
||
$repository->load(self::COLLECTION_ID); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
return 'Tmdb\Api\Collection'; | ||
} | ||
|
||
protected function getRepositoryClass() | ||
{ | ||
return 'Tmdb\Repository\CollectionRepository'; | ||
} | ||
} |
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,38 @@ | ||
<?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\Repository; | ||
|
||
class CompanyRepositoryTest extends TestCase | ||
{ | ||
const COMPANY_ID = 120; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldLoadCompany() | ||
{ | ||
$repository = $this->getRepositoryWithMockedHttpClient(); | ||
|
||
$repository->load(self::COMPANY_ID); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
return 'Tmdb\Api\Company'; | ||
} | ||
|
||
protected function getRepositoryClass() | ||
{ | ||
return 'Tmdb\Repository\CompanyRepository'; | ||
} | ||
} |
Oops, something went wrong.