Navigation Menu

Skip to content

Commit

Permalink
added a way to easily change the environment and the debug flag in fu…
Browse files Browse the repository at this point in the history
…nctional tests
  • Loading branch information
fabpot committed Jun 10, 2010
1 parent defa307 commit 77d3f92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/Symfony/Foundation/Test/WebTestCase.php
Expand Up @@ -23,11 +23,15 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
/**
* Creates a Client.
*
* @param string $environment The environment
* @param Boolean $debug The debug flag
* @param array $server An array of server parameters
*
* @return Symfony\Foundation\Test\Client A Client instance
*/
public function createClient(array $server = array())
public function createClient($environment = 'test', $debug = true, array $server = array())
{
$kernel = $this->createKernel();
$kernel = $this->createKernel($environment, $debug);
$kernel->boot();

$client = $kernel->getContainer()->getTest_ClientService();
Expand All @@ -40,7 +44,10 @@ public function createClient(array $server = array())
/**
* Creates a Kernel.
*
* @param string $environment The environment
* @param Boolean $debug The debug flag
*
* @return Symfony\Components\HttpKernel\HttpKernelInterface A HttpKernelInterface instance
*/
abstract protected function createKernel();
abstract protected function createKernel($environment, $debug);
}
7 changes: 5 additions & 2 deletions src/Symfony/Framework/WebBundle/Test/WebTestCase.php
Expand Up @@ -29,9 +29,12 @@ abstract class WebTestCase extends BaseWebTestCase
* If you run tests with the PHPUnit CLI tool, everything will work as expected.
* If not, override this method in your test classes.
*
* @param string $environment The environment
* @param Boolean $debug The debug flag
*
* @return Symfony\Components\HttpKernel\HttpKernelInterface A HttpKernelInterface instance
*/
protected function createKernel()
protected function createKernel($environment, $debug)
{
// black magic below, you have been warned!
$dir = getcwd();
Expand All @@ -57,6 +60,6 @@ protected function createKernel()

require_once $file;

return new $class('test', true);
return new $class($environment, $debug);
}
}

0 comments on commit 77d3f92

Please sign in to comment.