Skip to content

Commit

Permalink
Fix PhpUnit 8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Feb 5, 2019
1 parent e80e193 commit 9850f7d
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Symfony/Bundle/FrameworkBundle/Test/BaseKernelTestCase.php
Expand Up @@ -20,8 +20,10 @@
* KernelTestCase is the base class for tests needing a Kernel.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
abstract class KernelTestCase extends TestCase
abstract class BaseKernelTestCase extends TestCase
{
protected static $class;

Expand Down Expand Up @@ -220,12 +222,4 @@ protected static function ensureKernelShutdown()
}
}
}

/**
* Clean up Kernel usage in this test.
*/
protected function tearDown()
{
static::ensureKernelShutdown();
}
}
20 changes: 20 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Test;

use PHPUnit\Runner\Version;

if (class_exists(Version::class) && version_compare(Version::id(), '8.0.0') >= 0) {
class_alias(KernelTestCaseNew::class, KernelTestCase::class, true);
} else {
class_alias(KernelTestCaseOld::class, KernelTestCase::class, true);
}
30 changes: 30 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCaseNew.php
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Test;

/**
* KernelTestCaseNew is the base class for tests needing a Kernel >= PHPUNIT 8.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
abstract class KernelTestCaseNew extends BaseKernelTestCase
{
/**
* Clean up Kernel usage in this test.
*/
protected function tearDown(): void
{
static::ensureKernelShutdown();
}
}
30 changes: 30 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCaseOld.php
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Test;

/**
* KernelTestCaseOld is the base class for tests needing a Kernel <= PHPUNIT 7.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
abstract class KernelTestCaseOld extends BaseKernelTestCase
{
/**
* Clean up Kernel usage in this test.
*/
protected function tearDown()
{
static::ensureKernelShutdown();
}
}

0 comments on commit 9850f7d

Please sign in to comment.