Skip to content

Commit

Permalink
Updating Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 3, 2014
1 parent 98afbf6 commit 22e3716
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 16 deletions.
24 changes: 24 additions & 0 deletions lib/Tmdb/Model/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class Collection extends AbstractModel {
*/
private $name;

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

/**
* @var Common\GenericCollection
*/
Expand All @@ -63,6 +68,7 @@ class Collection extends AbstractModel {
'backdrop_path',
'id',
'name',
'overview',
'poster_path',
);

Expand Down Expand Up @@ -162,6 +168,24 @@ public function getName()
return $this->name;
}

/**
* @param string $overview
* @return $this
*/
public function setOverview($overview)
{
$this->overview = $overview;
return $this;
}

/**
* @return string
*/
public function getOverview()
{
return $this->overview;
}

/**
* @param GenericCollection $parts
* @return $this
Expand Down
34 changes: 30 additions & 4 deletions test/Tmdb/Tests/Factory/CollectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,32 @@
class CollectionFactoryTest extends TestCase
{
/**
* @test
* @var Collection
*/
public function shouldConstructCollection()
private $collection;

public function setUp()
{
/**
* @var CollectionFactory $factory
*/
$factory = $this->getFactory();
$data = $this->loadByFile('collection/get.json');

$data['overview'] = 'external';

/**
* @var Collection $collection
*/
$collection = $factory->create($data);
$this->collection = $factory->create($data);
}

$this->assertInstanceOf('Tmdb\Model\Collection', $collection);
/**
* @test
*/
public function shouldConstructCollection()
{
$this->assertInstanceOf('Tmdb\Model\Collection', $this->collection);
}

/**
Expand Down Expand Up @@ -73,6 +83,22 @@ public function shouldBeAbleToCreateCollection()
$this->assertEquals(2, count($collection));
}

/**
* @test
*/
public function shouldBeFunctional()
{
$this->assertInstanceOf('Tmdb\Model\Image\BackdropImage', $this->collection->getBackdrop());
$this->assertEquals('/qCECROwx3TRUEgoZv2Mz2D723QC.jpg', $this->collection->getBackdropPath());
$this->assertEquals(10, $this->collection->getId());
$this->assertEquals('external', $this->collection->getOverview());
$this->assertInstanceOf('Tmdb\Model\Collection\Images', $this->collection->getImages());
$this->assertEquals('Star Wars Collection', $this->collection->getName());
$this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->collection->getParts());
$this->assertInstanceOf('Tmdb\Model\Image\PosterImage', $this->collection->getPoster());
$this->assertEquals('/ghd5zOQnDaDW1mxO7R5fXXpZMu.jpg', $this->collection->getPosterPath());
}

protected function getFactoryClass()
{
return 'Tmdb\Factory\CollectionFactory';
Expand Down
27 changes: 15 additions & 12 deletions test/Tmdb/Tests/HttpClient/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
*/
namespace Tmdb\Tests\HttpClient;

use Guzzle\Common\Event;
use \Exception;
use Tmdb\Api\AbstractApi;
use Tmdb\ApiToken;
use Tmdb\Client;
use Tmdb\HttpClient\HttpClient;
use Tmdb\Tests\TestCase;

Expand All @@ -29,7 +32,7 @@ class HttpClientTest extends TestCase
private $testApi;

/**
* @var HttpClient
* @var Client
*/
private $client;

Expand All @@ -40,7 +43,7 @@ public function setUp()
->setMethods(array())
->getMock();

$this->client = new HttpClient('http://www.google.com', array(), $this->guzzleMock);
$this->client = new Client(new ApiToken('abcdef'), $this->guzzleMock);
$this->testApi = new TestApi($this->client);
}

Expand Down Expand Up @@ -170,42 +173,42 @@ public function shouldBeAbleToOverrideClient()
}
}

class TestApi {
class TestApi extends AbstractApi {
/**
* @var \Tmdb\HttpClient\HttpClient
*/
private $client;
protected $client;

public function __construct($client)
{
$this->client = $client;
}

public function get() {
$this->client->get('/');
$this->client->getHttpClient()->get('/');
}

public function head() {
$this->client->head('/');
$this->client->getHttpClient()->head('/');
}

public function post() {
$this->client->post('/', array('id' => 1));
$this->client->getHttpClient()->post('/', array('id' => 1));
}

public function patch() {
$this->client->patch('http://www.google.com/');
$this->client->getHttpClient()->patch('http://www.google.com/');
}

public function delete() {
$this->client->delete('http://www.google.com/');
$this->client->getHttpClient()->delete('http://www.google.com/');
}

public function put() {
$this->client->put('http://www.google.com/');
$this->client->getHttpClient()->put('http://www.google.com/');
}

public function addSubscriber($event) {
$this->client->addSubscriber($event);
$this->client->getHttpClient()->addSubscriber($event);
}
}

0 comments on commit 22e3716

Please sign in to comment.