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
d43d291
commit 22cf331
Showing
5 changed files
with
372 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="test/bootstrap.php" | ||
> | ||
<testsuites> | ||
<testsuite name="php-tmdb-api Test Suite"> | ||
<directory>./test/Tmdb/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<groups> | ||
<exclude> | ||
<group>functional</group> | ||
</exclude> | ||
</groups> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./examples/</directory> | ||
<directory suffix=".php">./lib/Tmdb/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,248 @@ | ||
<?php | ||
/** | ||
* This file is part of the Wrike PHP API created by B-Found IM&S. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Wrike | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, B-Found Internet Marketing & Services | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Tests\Api; | ||
|
||
class MoviesTest extends TestCase | ||
{ | ||
const MOVIE_ID = 120; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetMovie() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID); | ||
|
||
$api->getMovie(self::MOVIE_ID); | ||
} | ||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAlternativeTitles() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/alternative_titles'); | ||
|
||
$api->getAlternativeTitles(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetCast() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/casts'); | ||
|
||
$api->getCast(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetImages() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/images'); | ||
|
||
$api->getImages(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetKeywords() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/keywords'); | ||
|
||
$api->getKeywords(self::MOVIE_ID); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function getReleases() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/releases'); | ||
|
||
$api->getReleases(self::MOVIE_ID); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetTrailers() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/trailers'); | ||
|
||
$api->getTrailers(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetTranslations() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/translations'); | ||
|
||
$api->getTranslations(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetSimilarMovies() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/similar_movies'); | ||
|
||
$api->getSimilarMovies(self::MOVIE_ID); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetReviews() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/reviews'); | ||
|
||
$api->getReviews(self::MOVIE_ID); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetLists() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/lists'); | ||
|
||
$api->getLists(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetChanges() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/' . self::MOVIE_ID . '/changes'); | ||
|
||
$api->getChanges(self::MOVIE_ID); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetLatest() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/latest'); | ||
|
||
$api->getLatest(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetUpcoming() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/upcoming'); | ||
|
||
$api->getUpcoming(); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetNowPlaying() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/now_playing'); | ||
|
||
$api->getNowPlaying(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetPopular() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/popular'); | ||
|
||
$api->getPopular(); | ||
} | ||
|
||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetTopRated() | ||
{ | ||
$api = $this->getApiMock(); | ||
$api->expects($this->once()) | ||
->method('get') | ||
->with('movie/top_rated'); | ||
|
||
$api->getTopRated(); | ||
} | ||
|
||
protected function getApiClass() { | ||
return 'Tmdb\Api\Movies'; | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
/** | ||
* This file is part of the Wrike PHP API created by B-Found IM&S. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package Wrike | ||
* @author Michael Roterman <[email protected]> | ||
* @copyright (c) 2013, B-Found Internet Marketing & Services | ||
* @version 0.0.1 | ||
*/ | ||
namespace Tmdb\Tests\Api; | ||
|
||
use Tmdb\ApiToken; | ||
|
||
abstract class TestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
abstract protected function getApiClass(); | ||
|
||
protected function getApiMock() | ||
{ | ||
$token = new ApiToken('abcdef'); | ||
|
||
$httpClient = $this->getMock('Guzzle\Http\Client', array('send')); | ||
$httpClient | ||
->expects($this->any()) | ||
->method('send'); | ||
|
||
$mock = $this->getMock('Tmdb\HttpClient\HttpClientInterface', array(), array(array(), $httpClient)); | ||
|
||
$client = new \Tmdb\Client($token, $httpClient); | ||
$client->setHttpClient($mock); | ||
|
||
return $this->getMockBuilder($this->getApiClass()) | ||
->setMethods(array('get', 'post', 'postRaw', 'patch', 'delete', 'put')) | ||
->setConstructorArgs(array($client)) | ||
->getMock(); | ||
} | ||
} |
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 ClientTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldNotHaveToPassHttpClientToConstructor() | ||
{ | ||
$token = new \Tmdb\ApiToken('abcdef'); | ||
$client = new \Tmdb\Client($token); | ||
|
||
$this->assertInstanceOf('Tmdb\HttpClient\HttpClient', $client->getHttpClient()); | ||
} | ||
} |
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,27 @@ | ||
<?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 | ||
*/ | ||
function includeIfExists($file) { | ||
if (file_exists($file)) { | ||
return include $file; | ||
} | ||
} | ||
|
||
if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../.composer/autoload.php'))) { | ||
die('You must set up the project dependencies, run the following commands:'.PHP_EOL. | ||
'curl -s http://getcomposer.org/installer | php'.PHP_EOL. | ||
'php composer.phar install'.PHP_EOL); | ||
} | ||
|
||
$loader->add('Tmdb\Tests', __DIR__); | ||
|
||
return $loader; |