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

Appearance settings

Commit fa2063e

Browse filesBrowse files
committed
[BroserKit] Enable passthrew header information on submit
This enables browser Testingtools like mink to pass headerfiles while doing a form submmit
1 parent 368a0c3 commit fa2063e
Copy full SHA for fa2063e

File tree

2 files changed

+16
-2
lines changed
Filter options

2 files changed

+16
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Client.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,11 @@ public function click(Link $link)
289289
*
290290
* @return Crawler
291291
*/
292-
public function submit(Form $form, array $values = array())
292+
public function submit(Form $form, array $values = array(), $serverParameters = array())
293293
{
294294
$form->setValues($values);
295295

296-
return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles());
296+
return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles(), $serverParameters);
297297
}
298298

299299
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/ClientTest.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,20 @@ public function testSubmitPreserveAuth()
367367
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
368368
}
369369

370+
public function testSubmitPassthrewHeaders()
371+
{
372+
$client = new TestClient();
373+
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
374+
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar');
375+
$headers = array('Accept-Language' => 'de');
376+
377+
$client->submit($crawler->filter('input')->form(), array(), $headers);
378+
379+
$server = $client->getRequest()->getServer();
380+
$this->assertArrayHasKey('Accept-Language', $server);
381+
$this->assertEquals('de', $server['Accept-Language']);
382+
}
383+
370384
public function testFollowRedirect()
371385
{
372386
$client = new TestClient();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.