8000 [FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS · symfony/symfony@d102fc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d102fc0

Browse files
committed
[FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS
1 parent 08aa6a8 commit d102fc0

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

UPGRADE-3.4.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ Finder
88
deprecated and will be removed in 4.0 as it used to fix a bug which existed
99
before version 5.5.23/5.6.7
1010

11+
FrameworkBundle
12+
---------------
13+
14+
* Using the `KERNEL_DIR` environment variable or the automatic guessing based
15+
on the `phpunit.xml` / `phpunit.xml.dist` file location is deprecated since 3.4.
16+
Set the `KERNEL_CLASS` environment variable to the fully-qualified class name
17+
of your Kernel instead. Not setting the `KERNEL_CLASS` environment variable
18+
will throw an exception on 4.0 unless you override the `KernelTestCase::createKernel()`
19+
or `KernelTestCase::getKernelClass()` method.
20+
21+
* The `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
22+
methods are deprecated since 3.4 and will be removed in 4.0.
23+
1124
Validator
1225
---------
1326

UPGRADE-4.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,15 @@ FrameworkBundle
333333
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ValidateWorkflowsPass` class
334334
has been removed. Use the `Symfony\Component\Workflow\DependencyInjection\ValidateWorkflowsPass`
335335
class instead.
336+
337+
* Using the `KERNEL_DIR` environment variable and the automatic guessing based
338+
on the `phpunit.xml` file location have been removed from the `KernelTestCase::getKernelClass()`
339+
method implementation. Set the `KERNEL_CLASS` environment variable to the
340+
fully-qualified class name of your Kernel or override the `KernelTestCase::createKernel()`
341+
or `KernelTestCase::getKernelClass()` method instead.
342+
343+
* The methods `KernelTestCase::getPhpUnitXmlDir()` and `KernelTestCase::getPhpUnitCliConfigArgument()`
344+
have been removed.
336345

337346
HttpFoundation
338347
--------------

src/Symfony/Bundle/FrameworkBundle/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

src/Symfony/Bundle/FrameworkBundle/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)
0