diff --git a/examples/companies/model/get.php b/examples/companies/model/get.php index 31467c72..07f11c85 100644 --- a/examples/companies/model/get.php +++ b/examples/companies/model/get.php @@ -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); \ No newline at end of file diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index f84a6d9f..fb5f28fa 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -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 * diff --git a/lib/Tmdb/HttpClient/HttpClient.php b/lib/Tmdb/HttpClient/HttpClient.php index f8b148de..9eb6817d 100644 --- a/lib/Tmdb/HttpClient/HttpClient.php +++ b/lib/Tmdb/HttpClient/HttpClient.php @@ -75,6 +75,14 @@ public function clearHeaders() $this->headers = array(); } + /** + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + /** * @param array $headers */ diff --git a/lib/Tmdb/Model/Company.php b/lib/Tmdb/Model/Company.php index 83bbda4b..59b27a12 100644 --- a/lib/Tmdb/Model/Company.php +++ b/lib/Tmdb/Model/Company.php @@ -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', diff --git a/test/Tmdb/Tests/ClientTest.php b/test/Tmdb/Tests/ClientTest.php index 0f4c60fd..fd5eedb2 100644 --- a/test/Tmdb/Tests/ClientTest.php +++ b/test/Tmdb/Tests/ClientTest.php @@ -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' - ); - } } \ No newline at end of file diff --git a/test/Tmdb/Tests/Factory/CompanyFactoryTest.php b/test/Tmdb/Tests/Factory/CompanyFactoryTest.php new file mode 100644 index 00000000..462c9a8d --- /dev/null +++ b/test/Tmdb/Tests/Factory/CompanyFactoryTest.php @@ -0,0 +1,45 @@ + + * @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'; + } +} \ No newline at end of file diff --git a/test/Tmdb/Tests/Factory/GenreFactoryTest.php b/test/Tmdb/Tests/Factory/GenreFactoryTest.php index 8fcc9550..a5a3a832 100644 --- a/test/Tmdb/Tests/Factory/GenreFactoryTest.php +++ b/test/Tmdb/Tests/Factory/GenreFactoryTest.php @@ -40,11 +40,6 @@ public function shouldConstructGenres() } } - protected function getFactory() - { - return new GenreFactory(); - } - protected function getFactoryClass() { return 'Tmdb\Factory\GenreFactory'; diff --git a/test/Tmdb/Tests/Resources/company/get.json b/test/Tmdb/Tests/Resources/company/get.json new file mode 100644 index 00000000..23464781 --- /dev/null +++ b/test/Tmdb/Tests/Resources/company/get.json @@ -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} \ No newline at end of file