mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Fixed PjaxResponseNegotiatorTest
This commit is contained in:
parent
12f2e1e176
commit
b4fb174809
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user