Commit 5630a8b5 authored by Klaus Silveira's avatar Klaus Silveira

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

parent 2bd47d64
...@@ -43,13 +43,12 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase ...@@ -43,13 +43,12 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
/** /**
* Creates a Client. * Creates a Client.
* *
* @param array $options An array of options to pass to the createKernel class
* @param array $server An array of server parameters * @param array $server An array of server parameters
* *
* @return Client A Client instance * @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 ...@@ -33,6 +33,12 @@ class WebTestCaseTest extends WebTestCase
return '<h1>title</h1>'; 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; return $app;
} }
...@@ -53,4 +59,18 @@ class WebTestCaseTest extends WebTestCase ...@@ -53,4 +59,18 @@ class WebTestCaseTest extends WebTestCase
$crawler = $client->request('GET', '/html'); $crawler = $client->request('GET', '/html');
$this->assertEquals('title', $crawler->filter('h1')->text()); $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