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
e62f084
commit ddc0af3
Showing
16 changed files
with
1,157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?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; | ||
|
||
use Tmdb\Factory\AccountFactory; | ||
use Tmdb\Model\Account; | ||
use Tmdb\Model\Collection\ResultCollection; | ||
|
||
class AccountFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldGetAccount() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
/** | ||
* @var Account $account | ||
*/ | ||
$account = $factory->create($this->loadByFile('account/get.json')); | ||
|
||
$this->assertEquals(36, $account->getId()); | ||
$this->assertEquals(false, $account->getIncludeAdult()); | ||
$this->assertEquals('US', $account->getIso31661()); | ||
$this->assertEquals('en', $account->getIso6391()); | ||
$this->assertEquals('John Doe', $account->getName()); | ||
$this->assertEquals('johndoe', $account->getUsername()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetLists() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
/** | ||
* @var ResultCollection $collection | ||
*/ | ||
$collection = $factory->createResultCollection($this->loadByFile('account/lists.json'), 'createListItem'); | ||
|
||
$this->assertInstanceOf('Tmdb\Model\Collection\ResultCollection', $collection); | ||
$this->assertEquals(1, $collection->getPage()); | ||
$this->assertEquals(1, $collection->getTotalPages()); | ||
$this->assertEquals(15, $collection->getTotalResults()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetFavoriteMovies() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
/** | ||
* @var ResultCollection $collection | ||
*/ | ||
$collection = $factory->createResultCollection($this->loadByFile('account/favorite_movies.json'), 'createMovie'); | ||
|
||
$this->assertInstanceOf('Tmdb\Model\Collection\ResultCollection', $collection); | ||
$this->assertEquals(1, $collection->getPage()); | ||
$this->assertEquals(2, $collection->getTotalPages()); | ||
$this->assertEquals(34, $collection->getTotalResults()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldCreateStatus() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$status = $factory->createStatusResult($this->loadByFile('account/favorite.json')); | ||
|
||
$this->assertEquals(12, $status->getStatusCode()); | ||
$this->assertEquals('The item/record was updated successfully', $status->getStatusMessage()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetRatedMovies() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
/** | ||
* @var ResultCollection $collection | ||
*/ | ||
$collection = $factory->createResultCollection($this->loadByFile('account/rated_movies.json'), 'createMovie'); | ||
|
||
$this->assertInstanceOf('Tmdb\Model\Collection\ResultCollection', $collection); | ||
$this->assertEquals(1, $collection->getPage()); | ||
$this->assertEquals(12, $collection->getTotalPages()); | ||
$this->assertEquals(239, $collection->getTotalResults()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldGetMovieWatchlist() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
/** | ||
* @var ResultCollection $collection | ||
*/ | ||
$collection = $factory->createResultCollection($this->loadByFile('account/movie_watchlist.json'), 'createMovie'); | ||
|
||
$this->assertInstanceOf('Tmdb\Model\Collection\ResultCollection', $collection); | ||
$this->assertEquals(1, $collection->getPage()); | ||
$this->assertEquals(4, $collection->getTotalPages()); | ||
$this->assertEquals(67, $collection->getTotalResults()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldWatchlist() | ||
{ | ||
/** | ||
* @var AccountFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$status = $factory->createStatusResult($this->loadByFile('account/watchlist.json')); | ||
|
||
$this->assertEquals(1, $status->getStatusCode()); | ||
$this->assertEquals('Success', $status->getStatusMessage()); | ||
} | ||
|
||
protected function getFactoryClass() | ||
{ | ||
return 'Tmdb\Factory\AccountFactory'; | ||
} | ||
} |
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,101 @@ | ||
<?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; | ||
|
||
use Tmdb\Factory\AuthenticationFactory; | ||
|
||
class AuthenticationFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function shouldCreateRequestToken() | ||
{ | ||
/** | ||
* @var AuthenticationFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$token = $factory->createRequestToken($this->loadByFile('authentication/request_token.json')); | ||
|
||
$this->assertEquals('09-02-2012', $token->getExpiresAt()->format('d-m-Y')); | ||
$this->assertEquals('641bf16c663db167c6cffcdff41126039d4445bf', $token->getToken()); | ||
$this->assertEquals(true, $token->getSuccess()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldCreateSessionToken() | ||
{ | ||
/** | ||
* @var AuthenticationFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$token = $factory->createSessionToken($this->loadByFile('authentication/session_token.json')); | ||
|
||
$this->assertEquals('80b2bf99520cd795ff54e31af97917bc9e3a7c8c', $token->getToken()); | ||
$this->assertEquals(true, $token->getSuccess()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldCreateGuestSessionToken() | ||
{ | ||
/** | ||
* @var AuthenticationFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$token = $factory->createGuestSessionToken($this->loadByFile('authentication/guest_session_token.json')); | ||
|
||
$this->assertEquals('04-12-2012', $token->getExpiresAt()->format('d-m-Y')); | ||
$this->assertEquals('0c550fd5da2fc3f321ab3bs9b60ca108', $token->getToken()); | ||
$this->assertEquals(true, $token->getSuccess()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @expectedException \Tmdb\Exception\NotImplementedException | ||
*/ | ||
public function shouldThrowExceptionForCreate() | ||
{ | ||
/** | ||
* @var AuthenticationFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$factory->create(array()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @expectedException \Tmdb\Exception\NotImplementedException | ||
*/ | ||
public function shouldThrowExceptionForCreateCollection() | ||
{ | ||
/** | ||
* @var AuthenticationFactory $factory | ||
*/ | ||
$factory = $this->getFactory(); | ||
|
||
$factory->createCollection(array()); | ||
} | ||
|
||
protected function getFactoryClass() | ||
{ | ||
return 'Tmdb\Factory\AuthenticationFactory'; | ||
} | ||
} |
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
Oops, something went wrong.