Skip to content

Commit

Permalink
Fixing unit tests of Network
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Mar 2, 2014
1 parent bc8be43 commit c6ec372
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Tmdb/Api/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public function getNewToken()
*/
public function authenticateRequestToken($token)
{
//@codeCoverageIgnoreStart
header(sprintf(
'Location: %s/%s',
self::REQUEST_TOKEN_URI,
$token
));
//@codeCoverageIgnoreEnd
}

/**
Expand All @@ -63,10 +65,12 @@ public function getNewSession($requestToken)
{
try {
return $this->get('authentication/session/new', array('request_token' => $requestToken));
//@codeCoverageIgnoreStart
} catch (\Exception $e) {
if ($e->getCode() == 401) {
throw new UnauthorizedRequestTokenException("The request token has not been validated yet.");
}
//@codeCoverageIgnoreEnd
}
}

Expand Down
14 changes: 14 additions & 0 deletions lib/Tmdb/Model/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,23 @@
*/
class Network extends AbstractModel
{
/**
* @var integer
*/
private $id;

/**
* @var string
*/
private $name;

/**
* Properties that are available in the API
*
* These properties are hydrated by the ObjectHydrator, all the other properties are handled by the factory.
*
* @var array
*/
public static $properties = array(
'id',
'name',
Expand Down
13 changes: 13 additions & 0 deletions test/Tmdb/Tests/Api/PeopleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ public function shouldGetChanges()
$api->getChanges(self::PERSON_ID);
}

/**
* @test
*/
public function shouldGetExternalIds()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('person/' . self::PERSON_ID . '/external_ids');

$api->getExternalIds(self::PERSON_ID);
}

/**
* @test
*/
Expand Down
37 changes: 37 additions & 0 deletions test/Tmdb/Tests/Model/NetworkTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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\Common\ObjectHydrator;
use Tmdb\Model\Network;

class NetworkTest extends TestCase
{
/**
* @test
*/
public function shouldBeFunctional()
{
$data = array(
'id' => 1,
'name' => 'name',
);

$hydrator = new ObjectHydrator();

$object = $hydrator->hydrate(new Network(), $data);

$this->assertEquals(1, $object->getId());
$this->assertEquals('name', $object->getName());
}
}

0 comments on commit c6ec372

Please sign in to comment.