Skip to content

Commit

Permalink
[FrameworkBundle] tweaked previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 13, 2011
1 parent b4ac798 commit 7b940ce
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php
Expand Up @@ -46,11 +46,14 @@ public function createClient(array $options = array(), array $server = array())
}

/**
* Find the directory where the phpunit.xml(.dist) is stored
* Finds the directory where the phpunit.xml(.dist) is stored.
*
* @return string directory with the phpunit.xml(.dist)
* If you run tests with the PHPUnit CLI tool, everything will work as expected.
* If not, override this method in your test classes.
*
* @return string The directory where phpunit.xml(.dist) is stored
*/
protected function findPhpUnitXmlDir()
protected function getPhpUnitXmlDir()
{
$dir = getcwd();
if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
Expand All @@ -77,13 +80,15 @@ protected function findPhpUnitXmlDir()
}

/**
* Attempts to guess the kernel location
* Attempts to guess the kernel location.
*
* @return array file and class name
* When the Kernel is located, the file is required.
*
* @return string The Kernel class name
*/
protected function findKernel()
protected function getKernelClass()
{
$dir = isset($_SERVER['KERNEL_DIR']) ? $_SERVER['KERNEL_DIR'] : $this->findPhpUnitXmlDir();
$dir = isset($_SERVER['KERNEL_DIR']) ? $_SERVER['KERNEL_DIR'] : $this->getPhpUnitXmlDir();

$finder = new Finder();
$finder->name('*Kernel.php')->in($dir);
Expand All @@ -94,15 +99,14 @@ protected function findKernel()
$file = current(iterator_to_array($finder));
$class = $file->getBasename('.php');

return array($file, $class);
require_once $file;

return $class;
}

/**
* Creates a Kernel.
*
* If you run tests with the PHPUnit CLI tool, everything will work as expected.
* If not, override this method in your test classes.
*
* Available options:
*
* * environment
Expand All @@ -114,9 +118,7 @@ protected function findKernel()
*/
protected function createKernel(array $options = array())
{
list($file, $class) = $this->findKernel();

require_once $file;
$class = $this->getKernelClass();

return new $class(
isset($options['environment']) ? $options['environment'] : 'test',
Expand Down

0 comments on commit 7b940ce

Please sign in to comment.