-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,61 @@ | |
*/ | ||
class RelTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testSimpleTextRelationPassesThroughData() | ||
{ | ||
$router = new \Respect\Rest\Router; | ||
$router->get('/', function() { | ||
return array(); | ||
})->rel(array( | ||
'item' => '/foo' | ||
)); | ||
$response = $router->dispatch('GET', '/')->response(); | ||
|
||
$this->assertArrayHasKey( | ||
'links', | ||
$response, | ||
'An array of links should be returned when a rel succeeds' | ||
); | ||
|
||
$this->assertArrayHasKey( | ||
'item', | ||
$response['links'], | ||
'The links array should contain the related link' | ||
); | ||
|
||
$this->assertContains( | ||
'/foo', | ||
$response['links']['item'], | ||
'The related link key should contain the specified rel value' | ||
); | ||
} | ||
|
||
public function testMultipleTextRelationPassesThroughData() | ||
{ | ||
$router = new \Respect\Rest\Router; | ||
$router->get('/', function() { | ||
return array(); | ||
})->rel(array( | ||
'item' => array('/foo', '/bar') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alganet
Member
|
||
)); | ||
$response = $router->dispatch('GET', '/')->response(); | ||
|
||
$this->assertCount( | ||
2, | ||
$response['links']['item'], | ||
'The related link key should contain the exact number of related items' | ||
); | ||
|
||
$this->assertContains( | ||
'/foo', | ||
$response['links']['item'], | ||
'The related link key should contain the specified rel value' | ||
); | ||
|
||
$this->assertContains( | ||
'/bar', | ||
$response['links']['item'], | ||
'The related link key should contain the specified rel value' | ||
); | ||
} | ||
} |
1 comment
on commit 67915d9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't seen that. How did I miss that?!
Fucking awesome.
How about :
I'm not quite feeling the list of urls? Would I be on the right track, or have you something else in mind.
Awesome stretch you covered, well done! =)