8000 feature #22675 [FrameworkBundle] KernelTestCase: deprecate not using … · symfony/symfony@e4e1b81 · GitHub
[go: up one dir, main page]

Skip to content

Commit e4e1b81

Browse files
committed
feature #22675 [FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #22668 (comment) | License | MIT | Doc PR | N/A Commits ------- d102fc0 [FrameworkBundle] KernelTestCase: deprecate not using KERNEL_CLASS
2 parents ea3ed4c + d102fc0 commit e4e1b81

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
@@ -13,6 +13,19 @@ Finder
1313
deprecated and will be removed in 4.0 as it used to fix a bug which existed
1414
before version 5.5.23/5.6.7.
1515

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

UPGRADE-4.0.md

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

334343
* The `Symfony\Bundle\FrameworkBundle\Validator\ConstraintValidatorFactory` class has been removed.
335344
Use `Symfony\Component\Validator\ContainerConstraintValidatorFactory` instead.

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