Commit 62f26f1e authored by Fabien Potencier's avatar Fabien Potencier

merged branch klaussilveira/master (PR #344)

Commits
-------

5630a8b5 Removed options since Silex WebTestCase has no createKernel, added missing server parameter array

Discussion
----------

Fix server parameter array not being passed to new Client instance, unused createKernel options

Removed options since Silex WebTestCase has no createKernel and added missing server parameter array.

---------------------------------------------------------------------------

by igorw at 2012-06-01T20:16:27Z

Looks good.
parents 2bd47d64 5630a8b5
......@@ -43,13 +43,12 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
/**
* Creates a Client.
*
* @param array $options An array of options to pass to the createKernel class
* @param array $server An array of server parameters
*
* @return Client A Client instance
*/
public function createClient(array $options = array(), array $server = array())
public function createClient(array $server = array())
{
return new Client($this->app);
return new Client($this->app, $server);
}
}
......@@ -33,6 +33,12 @@ class WebTestCaseTest extends WebTestCase
return '<h1>title</h1>';
});
$app->match('/server', function () use ($app) {
$user = $app['request']->server->get('PHP_AUTH_USER');
$pass = $app['request']->server->get('PHP_AUTH_PW');
return "<h1>$user:$pass</h1>";
});
return $app;
}
......@@ -53,4 +59,18 @@ class WebTestCaseTest extends WebTestCase
$crawler = $client->request('GET', '/html');
$this->assertEquals('title', $crawler->filter('h1')->text());
}
public function testServerVariables()
{
$user = 'klaus';
$pass = '123456';
$client = $this->createClient(array(
'PHP_AUTH_USER' => $user,
'PHP_AUTH_PW' => $pass,
));
$crawler = $client->request('GET', '/server');
$this->assertEquals("$user:$pass", $crawler->filter('h1')->text());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment