This repository has been archived by the owner on Nov 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PagedList: Check if uri is valid in constructor
- Loading branch information
Showing
4 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Pinterest\Tests; | ||
|
||
use InvalidArgumentException; | ||
use Pinterest\Authentication; | ||
use Pinterest\Objects\PagedList; | ||
use Pinterest\Objects\User; | ||
|
||
class PagedListTest extends TestCase | ||
{ | ||
public function test_it_only_accepts_pinterest_objects() | ||
{ | ||
new PagedList(array(new User())); | ||
|
||
$this->setExpectedException(InvalidArgumentException::class); | ||
new PagedList(array(1)); | ||
|
||
$this->setExpectedException(InvalidArgumentException::class); | ||
new PagedList(array(1, new User())); | ||
} | ||
|
||
public function test_it_has_more_items() | ||
{ | ||
new PagedList(array(new User()), Authentication::BASE_URI.'/me'); | ||
|
||
$this->setExpectedException(InvalidArgumentException::class); | ||
new PagedList(array(new User()), 'next-uri'); | ||
} | ||
|
||
public function test_it_returns_the_next_uri() | ||
{ | ||
$uri = Authentication::BASE_URI.'/v1/me'; | ||
$pagedList = new PagedList(array(new User()), $uri); | ||
$this->assertTrue($pagedList->hasNext()); | ||
$this->assertEquals($uri, $pagedList->getNextUrl()); | ||
|
||
$pagedList = new PagedList(array(new User())); | ||
$this->assertFalse($pagedList->hasNext()); | ||
} | ||
|
||
public function test_it_returns_the_items() | ||
{ | ||
$items = array(new User(), new User()); | ||
$pagedList = new PagedList($items); | ||
$this->assertEquals($items, $pagedList->items()); | ||
} | ||
} |