Skip to content

Commit

Permalink
Adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Jan 28, 2014
1 parent a970b51 commit 53cf259
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/companies/model/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
$client = new \Tmdb\Client($token);

$repository = new \Tmdb\Repository\CompanyRepository($client);
$company = $repository->load(28);
$company = $repository->load(1);

var_dump($company);
8 changes: 8 additions & 0 deletions lib/Tmdb/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ public function setHeaders(array $headers)
$this->httpClient->setHeaders($headers);
}

/**
* @return array
*/
public function getHeaders()
{
$this->httpClient->getHeaders();
}

/**
* Return the base url with preferred schema
*
Expand Down
8 changes: 8 additions & 0 deletions lib/Tmdb/HttpClient/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public function clearHeaders()
$this->headers = array();
}

/**
* @return array
*/
public function getHeaders()
{
return $this->headers;
}

/**
* @param array $headers
*/
Expand Down
5 changes: 5 additions & 0 deletions lib/Tmdb/Model/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Company extends AbstractModel {
private $name;
private $parentCompany;

public function __construct()
{
$this->logo = new LogoImage();
}

public static $_properties = array(
'description',
'headquarters',
Expand Down
12 changes: 0 additions & 12 deletions test/Tmdb/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,4 @@ public function shouldNotHaveToPassHttpClientToConstructor()
$this->assertInstanceOf('Tmdb\HttpClient\HttpClient', $client->getHttpClient());
}

/**
* @test
*/
public function clearHeadersFunctionActuallyClears()
{
$token = new \Tmdb\ApiToken('abcdef');
$client = new \Tmdb\Client($token);

$headers = array(
'a' => 'b'
);
}
}
45 changes: 45 additions & 0 deletions test/Tmdb/Tests/Factory/CompanyFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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;

class CompanyFactoryTest extends TestCase
{
const COMPANY_ID = 1;

/**
* @test
*/
public function shouldConstructCompany()
{
$factory = $this->getFactory();
$data = (array) $this->loadByFile('company/get.json');

$company = $factory->create($data);

$this->assertInstanceOf('Tmdb\Model\Company', $company);
$this->assertInstanceOf('Tmdb\Model\Image\LogoImage', $company->getLogo());

$this->assertEquals(null, $company->getDescription());
$this->assertEquals('San Francisco, California', $company->getHeadquarters());
$this->assertEquals('http://www.lucasfilm.com', $company->getHomepage());
$this->assertEquals(1, $company->getId());
$this->assertEquals('/8rUnVMVZjlmQsJ45UGotD0Uznxj.png', $company->getLogoPath());
$this->assertEquals('Lucasfilm', $company->getName());
$this->assertEquals(null, $company->getParentCompany());
}

protected function getFactoryClass()
{
return 'Tmdb\Factory\CompanyFactory';
}
}
5 changes: 0 additions & 5 deletions test/Tmdb/Tests/Factory/GenreFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public function shouldConstructGenres()
}
}

protected function getFactory()
{
return new GenreFactory();
}

protected function getFactoryClass()
{
return 'Tmdb\Factory\GenreFactory';
Expand Down
1 change: 1 addition & 0 deletions test/Tmdb/Tests/Resources/company/get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"description":null,"headquarters":"San Francisco, California","homepage":"http:\/\/www.lucasfilm.com","id":1,"logo_path":"\/8rUnVMVZjlmQsJ45UGotD0Uznxj.png","name":"Lucasfilm","parent_company":null}

0 comments on commit 53cf259

Please sign in to comment.