Skip to content

Commit

Permalink
Adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Jan 29, 2014
1 parent 43253b4 commit 54ddb38
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/Tmdb/Model/Collection/ResultCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ResultCollection extends GenericCollection {
*/
public function setPage($page)
{
$this->page = $page;
$this->page = (int) $page;
return $this;
}

Expand All @@ -63,7 +63,7 @@ public function getPage()
*/
public function setTotalPages($totalPages)
{
$this->totalPages = $totalPages;
$this->totalPages = (int) $totalPages;
return $this;
}

Expand All @@ -81,7 +81,7 @@ public function getTotalPages()
*/
public function setTotalResults($totalResults)
{
$this->totalResults = $totalResults;
$this->totalResults = (int) $totalResults;
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Model/Query/Discover/DiscoverMoviesQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function withCompanies($companies)
*/
public function withCompaniesAnd(array $companies = array())
{
return $this->withGenres(
return $this->withCompanies(
implode(',', $companies)
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Tmdb/Model/Query/Discover/DiscoverTvQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function withNetworks($networks)
*/
public function withNetworksAnd(array $networks = array())
{
return $this->withGenres(
return $this->withNetworks(
implode(',', $networks)
);
}
Expand Down
40 changes: 40 additions & 0 deletions test/Tmdb/Tests/Model/Query/ChangesQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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\Query;

use Tmdb\Model\Query\ChangesQuery;
use Tmdb\Tests\TestCase;

class ChangesQueryTest extends TestCase
{
/**
* @test
*/
public function shouldCreateValidQuery()
{
$query = new ChangesQuery();

$now = new \DateTime();
$tomorrow = new \DateTime('tomorrow');

$query
->from($now)
->to($tomorrow)
->page(1)
;

$this->assertEquals($now->format('Y-m-d'), $query->get('from'));
$this->assertEquals($tomorrow->format('Y-m-d'), $query->get('to'));
$this->assertEquals(1, $query->get('page'));
}
}
51 changes: 51 additions & 0 deletions test/Tmdb/Tests/Model/Query/Discover/DiscoverMoviesQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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\Query;

use Tmdb\Model\Query\Discover\DiscoverMoviesQuery;
use Tmdb\Tests\TestCase;

class DiscoverMoviesQueryTest extends TestCase
{
/**
* @todo expand
* @test
*/
public function shouldCreateValidQuery()
{
$query = new DiscoverMoviesQuery();
$now = new \DateTime();

$query
->page(1)
->language('en')
->sortBy('sort')
->includeAdult(false)
->year($now)
->primaryReleaseYear($now)
->voteCountGte(5)
->voteAverageGte(3)
->withGenres(array(15,18))
->withGenresAnd(array(18))
->withGenresOr(array(1,2))
->releaseDateGte($now)
->releaseDateLte($now)
->certificationCountry('NL')
->certificationLte(1)
->withCompanies(array(1))
->withCompaniesAnd(array(2,5))
;

$this->assertEquals(13, count($query));
}
}
47 changes: 47 additions & 0 deletions test/Tmdb/Tests/Model/Query/Discover/DiscoverTvQueryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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\Query;

use Tmdb\Model\Query\Discover\DiscoverTvQuery;
use Tmdb\Tests\TestCase;

class DiscoverTvQueryTest extends TestCase
{
/**
* @todo expand
* @test
*/
public function shouldCreateValidQuery()
{
$query = new DiscoverTvQuery();
$now = new \DateTime();

$query
->page(1)
->language('en')
->sortBy('sort')
->firstAirDateYear($now)
->voteCountGte(5)
->voteAverageGte(3)
->withGenres(array(15,18))
->withGenresOr(array(1,2))
->withGenresAnd(array(18))
->firstAirDateGte($now)
->firstAirDateLte($now)
->withNetworks(array(1,2))
->withNetworksAnd(array(1,2,3))
;

$this->assertEquals(10, count($query));
}
}

0 comments on commit 54ddb38

Please sign in to comment.