Skip to content

Commit 817c1a2

Browse files
committed
[FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS
1 parent bca1b27 commit 817c1a2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* Deprecated using the `KERNEL_DIR` environment variable with `KernelTestCase::getKernelClass()`.
8+
* Deprecated the `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()` methods.
9+
410
3.3.0
511
-----
612

Test/KernelTestCase.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ abstract class KernelTestCase extends TestCase
3939
* @return string The directory where phpunit.xml(.dist) is stored
4040
*
4141
* @throws \RuntimeException
42+
*
43+
* @deprecated since 3.4 and will be removed in 4.0.
4244
*/
4345
protected static function getPhpUnitXmlDir()
4446
{
47+
@trigger_error(sprintf('The %s() method is deprecated since 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
48+
4549
if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
4650
throw new \RuntimeException('You must override the KernelTestCase::createKernel() method.');
4751
}
@@ -72,9 +76,13 @@ protected static function getPhpUnitXmlDir()
7276
* the last configuration argument.
7377
*
7478
* @return string The value of the PHPUnit CLI configuration option
79+
*
80+
* @deprecated since 3.4 and will be removed in 4.0.
7581
*/
7682
private static function getPhpUnitCliConfigArgument()
7783
{
84+
@trigger_error(sprintf('The %s() method is deprecated since 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
85+
7886
$dir = null;
7987
$reversedArgs = array_reverse($_SERVER['argv']);
8088
foreach ($reversedArgs as $argIndex => $testArg) {
@@ -112,6 +120,8 @@ protected static function getKernelClass()
112120
}
113121

114122
return $class;
123+
} else {
124+
@trigger_error(sprintf('Using the KERNEL_DIR environment variable or the automatic guessing based on the phpunit.xml / phpunit.xml.dist file location is deprecated since 3.4. Set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel instead. Not setting the KERNEL_CLASS environment variable will throw an exception on 4.0 unless you override the %1$::createKernel() or %1$::getKernelClass() method.', static::class), E_USER_DEPRECATED);
115125
}
116126

117127
if (isset($_SERVER['KERNEL_DIR'])) {

0 commit comments

Comments
 (0)