Skip to content

Commit ba6fcfd

Browse files
nicolas-grekasNyholm
authored andcommitted
Fix phpunit 8 compat to unlock testing Symfony on PHP 7.4 (#102)
1 parent 6ce21ad commit ba6fcfd

5 files changed

Lines changed: 22 additions & 9 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"require-dev": {
3131
"phpunit/phpunit": "^4.8.35|^5.4.3",
3232
"cache/cache": "^1.0",
33-
"symfony/cache": "^3.1|^4.0|^5.0",
33+
"symfony/cache": "^3.4.31|^4.3.4|^5.0",
34+
"symfony/phpunit-bridge": "^4.4",
3435
"illuminate/cache": "^5.4|^5.5|^5.6",
3536
"tedivm/stash": "^0.14",
3637
"mockery/mockery": "^1.0"

src/CachePoolTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Cache\CacheItemInterface;
1616
use Psr\Cache\CacheItemPoolInterface;
17+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1718

1819
abstract class CachePoolTest extends TestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
/**
2124
* @type array with functionName => reason.
2225
*/
@@ -32,12 +35,12 @@ abstract class CachePoolTest extends TestCase
3235
*/
3336
abstract public function createCachePool();
3437

35-
protected function setUp()
38+
private function doSetUp()
3639
{
3740
$this->cache = $this->createCachePool();
3841
}
3942

40-
protected function tearDown()
43+
private function doTearDown()
4144
{
4245
if ($this->cache !== null) {
4346
$this->cache->clear();

src/HierarchicalCachePoolTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Cache\CacheItemPoolInterface;
16+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1617

1718
/**
1819
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1920
*/
2021
abstract class HierarchicalCachePoolTest extends TestCase
2122
{
23+
use ForwardCompatTestTrait;
24+
2225
/**
2326
* @type array with functionName => reason.
2427
*/
@@ -34,12 +37,12 @@ abstract class HierarchicalCachePoolTest extends TestCase
3437
*/
3538
abstract public function createCachePool();
3639

37-
protected function setUp()
40+
private function doSetUp()
3841
{
3942
$this->cache = $this->createCachePool();
4043
}
4144

42-
protected function tearDown()
45+
private function doTearDown()
4346
{
4447
if ($this->cache !== null) {
4548
$this->cache->clear();

src/SimpleCacheTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\SimpleCache\CacheInterface;
16+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1617

1718
abstract class SimpleCacheTest extends TestCase
1819
{
20+
use ForwardCompatTestTrait;
21+
1922
/**
2023
* @type array with functionName => reason.
2124
*/
@@ -46,12 +49,12 @@ public function advanceTime($seconds)
4649
sleep($seconds);
4750
}
4851

49-
protected function setUp()
52+
private function doSetUp()
5053
{
5154
$this->cache = $this->createSimpleCache();
5255
}
5356

54-
protected function tearDown()
57+
private function doTearDown()
5558
{
5659
if ($this->cache !== null) {
5760
$this->cache->clear();

src/TaggableCachePoolTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
use Cache\TagInterop\TaggableCacheItemPoolInterface;
1515
use PHPUnit\Framework\TestCase;
16+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1617

1718
/**
1819
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
1920
*/
2021
abstract class TaggableCachePoolTest extends TestCase
2122
{
23+
use ForwardCompatTestTrait;
24+
2225
/**
2326
* @type array with functionName => reason.
2427
*/
@@ -34,12 +37,12 @@ abstract class TaggableCachePoolTest extends TestCase
3437
*/
3538
abstract public function createCachePool();
3639

37-
protected function setUp()
40+
private function doSetUp()
3841
{
3942
$this->cache = $this->createCachePool();
4043
}
4144

42-
protected function tearDown()
45+
private function doTearDown()
4346
{
4447
if ($this->cache !== null) {
4548
$this->cache->clear();

0 commit comments

Comments
 (0)