MINOR Fixed PjaxResponseNegotiatorTest

This commit is contained in:
Ingo Schommer 2012-06-05 14:22:00 +02:00
parent 12f2e1e176
commit b4fb174809

View File

@ -6,7 +6,8 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
'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() {
@ -16,7 +17,8 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
));
$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() {
@ -28,11 +30,12 @@ class PjaxResponseNegotiatorTest extends SapphireTest {
$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);
}
}
}