Example #1
0
 public function testNonUniqueMultipleTextRelationPassesThroughData()
 {
     $router = new \Respect\Rest\Router();
     $router->get('/', function () {
         return array();
     })->rel(array('item' => array('/foo', '/bar')))->rel(array('item' => array('/baz')));
     $response = $router->dispatch('GET', '/')->response();
     $this->assertCount(3, $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');
     $this->assertContains('/baz', $response['links']['item'], 'The related link key should contain the specified rel value');
 }
Example #2
0
 public function testRoutineWhenShouldConsiderSyncedCallbackParameters()
 {
     $phpUnit = $this;
     $router = new \Respect\Rest\Router();
     $router->get('/speakers/*', function ($speakerName) {
         return "Hello {$speakerName}";
     })->when(function ($speakerName) use($phpUnit) {
         $phpUnit->assertEquals('alganet', $speakerName);
         return strlen($speakerName) >= 3;
     });
     $response = $router->dispatch('GET', '/speakers/alganet')->response();
     $this->assertEquals('Hello alganet', $response, 'This When routine accepts parameters longer than 3 chars, alganet is, so it should pass');
 }