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
f0fc9d1
commit 38450c0
Showing
6 changed files
with
135 additions
and
20 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,43 @@ | ||
<?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 MovieRepositoryTest extends TestCase | ||
{ | ||
const MOVIE_ID = 120; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldLoadMovie() | ||
{ | ||
$repository = $this->getRepositoryWithMockedClient(); | ||
|
||
$repository->getClient()->getHttpClient()->getClient() | ||
->expects($this->once()) | ||
->method('send') | ||
; | ||
|
||
$repository->load(self::MOVIE_ID); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
return 'Tmdb\Api\Movies'; | ||
} | ||
|
||
protected function getRepositoryClass() | ||
{ | ||
return 'Tmdb\Repository\MovieRepository'; | ||
} | ||
} |
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,55 @@ | ||
<?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; | ||
|
||
use Guzzle\Http\Message\Response; | ||
use Tmdb\ApiToken; | ||
use Tmdb\Client; | ||
|
||
abstract class TestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected $repository; | ||
|
||
abstract protected function getRepositoryClass(); | ||
|
||
protected function getRepositoryWithMockedClient() | ||
{ | ||
$class = $this->getRepositoryClass(); | ||
|
||
return new $class($this->getMockedTmdbClient()); | ||
} | ||
|
||
protected function getRepositoryMock($client = null, array $methods = array()) | ||
{ | ||
if ($client == null) { | ||
$client = $this->getMockedTmdbClient(); | ||
} | ||
|
||
return $this->getMock($this->getRepositoryClass(), array('getApi'), array($client)); | ||
} | ||
|
||
protected function getMockedTmdbClient() | ||
{ | ||
$token = new ApiToken('abcdef'); | ||
$response = new Response('200'); | ||
|
||
$httpClient = $this->getMock('Guzzle\Http\Client', array('send')); | ||
$httpClient | ||
->expects($this->any()) | ||
->method('send') | ||
->will($this->returnValue($response)) | ||
; | ||
|
||
return new Client($token, $httpClient); | ||
} | ||
} |