Skip to content

Commit

Permalink
Adding airing_today and fixing tests for on_the_air, fixes php-tmdb#23
Browse files Browse the repository at this point in the history
…and thus can be closed
  • Loading branch information
wtfzdotnet committed Mar 26, 2014
1 parent ef7af10 commit 2f3150f
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
21 changes: 21 additions & 0 deletions examples/tv/api/tv/airing_today.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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
*/
require_once '../../../../vendor/autoload.php';
require_once '../../../../apikey.php';

$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);

$result = $client->getTvApi()->getAiringToday();

var_dump($result);
14 changes: 14 additions & 0 deletions lib/Tmdb/Api/Tv.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,18 @@ public function getOnTheAir(array $parameters = array(), array $headers = array(
{
$this->get('tv/on_the_air', $parameters, $headers);
}

/**
* Get the list of TV shows that air today.
*
* Without a specified timezone, this query defaults to EST (Eastern Time UTC-05:00).
*
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getAiringToday(array $parameters = array(), array $headers = array())
{
$this->get('tv/airing_today', $parameters, $headers);
}
}
16 changes: 16 additions & 0 deletions lib/Tmdb/Repository/TvRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,20 @@ public function getOnTheAir(array $options = array(), array $headers = array())
$this->getApi()->getOnTheAir($options, $headers)
);
}

/**
* Get the list of TV shows that air today.
*
* Without a specified timezone, this query defaults to EST (Eastern Time UTC-05:00).
*
* @param array $options
* @param array $headers
* @return Tv[]
*/
public function getAiringToday(array $options = array(), array $headers = array())
{
return $this->getFactory()->createResultCollection(
$this->getApi()->getAiringToday($options, $headers)
);
}
}
26 changes: 26 additions & 0 deletions test/Tmdb/Tests/Api/TvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,32 @@ public function shouldGetTopRated()
$api->getTopRated();
}

/**
* @test
*/
public function shouldGetOnTheAir()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('tv/on_the_air');

$api->getOnTheAir();
}

/**
* @test
*/
public function shouldGetAiringToday()
{
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('tv/airing_today');

$api->getAiringToday();
}

protected function getApiClass()
{
return 'Tmdb\Api\Tv';
Expand Down
13 changes: 11 additions & 2 deletions test/Tmdb/Tests/Repository/TvRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,22 @@ public function shouldGetTranslations()

/**
* @test
* @todo fix later
*/
public function shouldGetOnTheAir()
{
$repository = $this->getRepositoryWithMockedHttpClient();

//$repository->getOnTheAir();
$repository->getOnTheAir();
}

/**
* @test
*/
public function shouldGetAiringToday()
{
$repository = $this->getRepositoryWithMockedHttpClient();

$repository->getAiringToday();
}

/**
Expand Down

0 comments on commit 2f3150f

Please sign in to comment.