Skip to content

Commit

Permalink
MINOR Fixed PjaxResponseNegotiatorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Jun 5, 2012
1 parent 12f2e1e commit b4fb174
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/control/PjaxResponseNegotiatorTest.php
Expand Up @@ -6,7 +6,8 @@ function testDefaultCallbacks() {
'default' => function() {return 'default response';},
));
$request = new SS_HTTPRequest('GET', '/'); // not setting pjax header
$this->assertEquals('default response', $negotiator->respond($request));
$response = $negotiator->respond($request);
$this->assertEquals('default response', $response->getBody());
}

function testSelectsFragmentByHeader() {
Expand All @@ -16,7 +17,8 @@ function testSelectsFragmentByHeader() {
));
$request = new SS_HTTPRequest('GET', '/');
$request->addHeader('X-Pjax', 'myfragment');
$this->assertEquals('myfragment response', $negotiator->respond($request));
$response = $negotiator->respond($request);
$this->assertEquals('{"myfragment":"myfragment response"}', $response->getBody());
}

function testMultipleFragments() {
Expand All @@ -28,11 +30,12 @@ function testMultipleFragments() {
$request = new SS_HTTPRequest('GET', '/');
$request->addHeader('X-Pjax', 'myfragment,otherfragment');
$request->addHeader('Accept', 'text/json');
$json = json_decode($negotiator->respond($request));
$response = $negotiator->respond($request);
$json = json_decode( $response->getBody());
$this->assertObjectHasAttribute('myfragment', $json);
$this->assertEquals('myfragment response', $json->myfragment);
$this->assertObjectHasAttribute('otherfragment', $json);
$this->assertEquals('otherfragment response', $json->otherfragment);
}

}
}

0 comments on commit b4fb174

Please sign in to comment.