8000 [BroserKit] Enable passthrew header information on submit · symfony/symfony@fa2063e · GitHub
[go: up one dir, main page]

Skip to content

Commit fa2063e

Browse 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

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines 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

Lines 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