You are here

public function ClientTest::testSubmitPreserveAuth in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/browser-kit/Tests/ClientTest.php \Symfony\Component\BrowserKit\Tests\ClientTest::testSubmitPreserveAuth()

File

vendor/symfony/browser-kit/Tests/ClientTest.php, line 317

Class

ClientTest

Namespace

Symfony\Component\BrowserKit\Tests

Code

public function testSubmitPreserveAuth() {
  $client = new TestClient(array(
    'PHP_AUTH_USER' => 'foo',
    'PHP_AUTH_PW' => 'bar',
  ));
  $client
    ->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
  $crawler = $client
    ->request('GET', 'http://www.example.com/foo/foobar');
  $server = $client
    ->getRequest()
    ->getServer();
  $this
    ->assertArrayHasKey('PHP_AUTH_USER', $server);
  $this
    ->assertEquals('foo', $server['PHP_AUTH_USER']);
  $this
    ->assertArrayHasKey('PHP_AUTH_PW', $server);
  $this
    ->assertEquals('bar', $server['PHP_AUTH_PW']);
  $client
    ->submit($crawler
    ->filter('input')
    ->form());
  $this
    ->assertEquals('http://www.example.com/foo', $client
    ->getRequest()
    ->getUri(), '->submit() submit forms');
  $server = $client
    ->getRequest()
    ->getServer();
  $this
    ->assertArrayHasKey('PHP_AUTH_USER', $server);
  $this
    ->assertEquals('foo', $server['PHP_AUTH_USER']);
  $this
    ->assertArrayHasKey('PHP_AUTH_PW', $server);
  $this
    ->assertEquals('bar', $server['PHP_AUTH_PW']);
}