Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ed0889

Browse files
author
Amrouche Hamza
committed
feature: transform both switchToXHR and removeXhr to a xhrRequest
1 parent6059bdc commit4ed0889

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

‎src/Symfony/Component/BrowserKit/Client.php‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@ public function getServerParameter($key, $default = '')
151151
returnisset($this->server[$key]) ?$this->server[$key] :$default;
152152
}
153153

154-
publicfunctionswitchToXHR()
154+
publicfunctionxmlHttpRequest(string$method,string$uri,array$parameters =array(),array$files =array(),array$server =array(),string$content =null,bool$changeHistory =true):Crawler
155155
{
156156
$this->setServerParameter('HTTP_X_REQUESTED_WITH','XMLHttpRequest');
157-
}
158157

159-
publicfunctionremoveXHR()
160-
{
161-
unset($this->server['HTTP_X_REQUESTED_WITH']);
158+
try {
159+
return$this->request($method,$uri,$parameters,$files,$server,$content,$changeHistory);
160+
}finally {
161+
unset($this->server['HTTP_X_REQUESTED_WITH']);
162+
}
162163
}
163164

164165
/**

‎src/Symfony/Component/BrowserKit/Tests/ClientTest.php‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ public function testGetRequestNull()
104104
$this->assertNull($client->getRequest());
105105
}
106106

107-
publicfunctiontestGetRequestWithXHR()
107+
publicfunctiontestXmlHttpRequest()
108108
{
109109
$client =newTestClient();
110-
$client->switchToXHR();
111-
$client->request('GET','http://example.com/',array(),array(),array(),null,true,true);
110+
$client->xmlHttpRequest('GET','http://example.com/',array(),array(),array(),null,true);
112111
$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'],'XMLHttpRequest');
113-
$client->removeXHR();
114112
$this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH',false));
115113
}
116114

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp