mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Formatting
This commit is contained in:
parent
2ef63ddbc1
commit
5a3cc9503b
@ -13,11 +13,11 @@ class PjaxResponseNegotiatorTest extends SapphireTest
|
|||||||
public function testDefaultCallbacks()
|
public function testDefaultCallbacks()
|
||||||
{
|
{
|
||||||
$negotiator = new PjaxResponseNegotiator(
|
$negotiator = new PjaxResponseNegotiator(
|
||||||
array(
|
[
|
||||||
'default' => function () {
|
'default' => function () {
|
||||||
return 'default response';
|
return 'default response';
|
||||||
},
|
},
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$request = new HTTPRequest('GET', '/'); // not setting pjax header
|
$request = new HTTPRequest('GET', '/'); // not setting pjax header
|
||||||
$request->setSession(new Session([]));
|
$request->setSession(new Session([]));
|
||||||
@ -28,14 +28,14 @@ class PjaxResponseNegotiatorTest extends SapphireTest
|
|||||||
public function testSelectsFragmentByHeader()
|
public function testSelectsFragmentByHeader()
|
||||||
{
|
{
|
||||||
$negotiator = new PjaxResponseNegotiator(
|
$negotiator = new PjaxResponseNegotiator(
|
||||||
array(
|
[
|
||||||
'default' => function () {
|
'default' => function () {
|
||||||
return 'default response';
|
return 'default response';
|
||||||
},
|
},
|
||||||
'myfragment' => function () {
|
'myfragment' => function () {
|
||||||
return 'myfragment response';
|
return 'myfragment response';
|
||||||
},
|
},
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$request = new HTTPRequest('GET', '/');
|
$request = new HTTPRequest('GET', '/');
|
||||||
$request->setSession(new Session([]));
|
$request->setSession(new Session([]));
|
||||||
@ -47,17 +47,17 @@ class PjaxResponseNegotiatorTest extends SapphireTest
|
|||||||
public function testMultipleFragments()
|
public function testMultipleFragments()
|
||||||
{
|
{
|
||||||
$negotiator = new PjaxResponseNegotiator(
|
$negotiator = new PjaxResponseNegotiator(
|
||||||
array(
|
[
|
||||||
'default' => function () {
|
'default' => function () {
|
||||||
return 'default response';
|
return 'default response';
|
||||||
},
|
},
|
||||||
'myfragment' => function () {
|
'myfragment' => function () {
|
||||||
return 'myfragment response';
|
return 'myfragment response';
|
||||||
},
|
},
|
||||||
'otherfragment' => function () {
|
'otherfragment' => function () {
|
||||||
return 'otherfragment response';
|
return 'otherfragment response';
|
||||||
},
|
},
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
$request = new HTTPRequest('GET', '/');
|
$request = new HTTPRequest('GET', '/');
|
||||||
$request->setSession(new Session([]));
|
$request->setSession(new Session([]));
|
||||||
@ -74,14 +74,14 @@ class PjaxResponseNegotiatorTest extends SapphireTest
|
|||||||
public function testFragmentsOverride()
|
public function testFragmentsOverride()
|
||||||
{
|
{
|
||||||
$negotiator = new PjaxResponseNegotiator(
|
$negotiator = new PjaxResponseNegotiator(
|
||||||
array(
|
[
|
||||||
'alpha' => function () {
|
'alpha' => function () {
|
||||||
return 'alpha response';
|
return 'alpha response';
|
||||||
},
|
},
|
||||||
'beta' => function () {
|
'beta' => function () {
|
||||||
return 'beta response';
|
return 'beta response';
|
||||||
}
|
},
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$request = new HTTPRequest('GET', '/');
|
$request = new HTTPRequest('GET', '/');
|
||||||
@ -89,7 +89,7 @@ class PjaxResponseNegotiatorTest extends SapphireTest
|
|||||||
$request->addHeader('X-Pjax', 'alpha');
|
$request->addHeader('X-Pjax', 'alpha');
|
||||||
$request->addHeader('Accept', 'application/json');
|
$request->addHeader('Accept', 'application/json');
|
||||||
|
|
||||||
$response = $negotiator->setFragmentOverride(array('beta'))->respond($request);
|
$response = $negotiator->setFragmentOverride(['beta'])->respond($request);
|
||||||
$json = json_decode($response->getBody());
|
$json = json_decode($response->getBody());
|
||||||
$this->assertFalse(isset($json->alpha));
|
$this->assertFalse(isset($json->alpha));
|
||||||
$this->assertObjectHasAttribute('beta', $json);
|
$this->assertObjectHasAttribute('beta', $json);
|
||||||
|
Loading…
Reference in New Issue
Block a user