Skip to content

Commit e778cf1

Browse files
committed
fixed previous merge
1 parent 0aeb394 commit e778cf1

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ abstract class KernelTestCase extends \PHPUnit_Framework_TestCase
3131
/**
3232
* Finds the directory where the phpunit.xml(.dist) is stored.
3333
*
34-
* If you run tests with the PHPUnit CLI tool, everything will work as
35-
* expected. If not, override this method in your test classes.
34+
* If you run tests with the PHPUnit CLI tool, everything will work as expected.
35+
* If not, override this method in your test classes.
3636
*
3737
* @return string The directory where phpunit.xml(.dist) is stored
3838
*
@@ -41,7 +41,7 @@ abstract class KernelTestCase extends \PHPUnit_Framework_TestCase
4141
protected static function getPhpUnitXmlDir()
4242
{
4343
if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
44-
throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
44+
throw new \RuntimeException('You must override the KernelTestCase::createKernel() method.');
4545
}
4646

4747
$dir = static::getPhpUnitCliConfigArgument();
@@ -66,10 +66,10 @@ protected static function getPhpUnitXmlDir()
6666
/**
6767
* Finds the value of the CLI configuration option.
6868
*
69-
* PHPUnit will use the last configuration argument on the command line, so
70-
* this only returns the last configuration argument.
69+
* PHPUnit will use the last configuration argument on the command line, so this only returns
70+
* the last configuration argument.
7171
*
72-
* @return string The value of the PHPUnit cli configuration option
72+
* @return string The value of the PHPUnit CLI configuration option
7373
*/
7474
private static function getPhpUnitCliConfigArgument()
7575
{
@@ -100,13 +100,21 @@ private static function getPhpUnitCliConfigArgument()
100100
*/
101101
protected static function getKernelClass()
102102
{
103-
$dir = isset($_SERVER['KERNEL_DIR']) ? $_SERVER['KERNEL_DIR'] : static::getPhpUnitXmlDir();
103+
$dir = $phpUnitDir = static::getPhpUnitXmlDir();
104+
105+
if (isset($_SERVER['KERNEL_DIR'])) {
106+
$dir = $_SERVER['KERNEL_DIR'];
107+
108+
if (!is_dir($dir) && is_dir("$phpUnitDir/$dir")) {
109+
$dir = "$phpUnitDir/$dir";
110+
}
111+
}
104112

105113
$finder = new Finder();
106114
$finder->name('*Kernel.php')->depth(0)->in($dir);
107115
$results = iterator_to_array($finder);
108116
if (!count($results)) {
109-
throw new \RuntimeException('Either set KERNEL_DIR in your phpunit.xml according to http://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the WebTestCase::createKernel() method.');
117+
throw new \RuntimeException('Either set KERNEL_DIR in your phpunit.xml according to http://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the KernelTestCase::createKernel() method.');
110118
}
111119

112120
$file = current($results);
@@ -155,7 +163,7 @@ protected static function createKernel(array $options = array())
155163
}
156164

157165
/**
158-
* Shutdown the Kernel.
166+
* Shuts the kernel down if it was used in the test.
159167
*/
160168
protected static function ensureKernelShutdown()
161169
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy