Skip to content

Commit b645f7b

Browse files
Make tests support phpunit 8
1 parent d10a8b1 commit b645f7b

14 files changed

+58
-22
lines changed

Test/ConstraintValidatorTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
abstract class ConstraintValidatorTestCase extends TestCase
3131
{
32-
use TestCaseSetUpTearDownTrait;
32+
use ForwardCompatTestTrait;
3333

3434
/**
3535
* @var ExecutionContextInterface

Test/TestCaseSetUpTearDownTrait.php renamed to Test/ForwardCompatTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* @internal
2424
*/
25-
trait TestCaseSetUpTearDownTrait
25+
trait ForwardCompatTestTrait
2626
{
2727
private function doSetUp(): void
2828
{
@@ -47,7 +47,7 @@ protected function tearDown(): void
4747
/**
4848
* @internal
4949
*/
50-
trait TestCaseSetUpTearDownTrait
50+
trait ForwardCompatTestTrait
5151
{
5252
/**
5353
* @return void

Tests/ConstraintViolationListTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@
1212
namespace Symfony\Component\Validator\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Validator\ConstraintViolation;
1617
use Symfony\Component\Validator\ConstraintViolationList;
1718

1819
class ConstraintViolationListTest extends TestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
protected $list;
2124

22-
protected function setUp()
25+
private function doSetUp()
2326
{
2427
$this->list = new ConstraintViolationList();
2528
}
2629

27-
protected function tearDown()
30+
private function doTearDown()
2831
{
2932
$this->list = null;
3033
}

Tests/Constraints/FileValidatorTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Component\HttpFoundation\File\UploadedFile;
1516
use Symfony\Component\Validator\Constraints\File;
1617
use Symfony\Component\Validator\Constraints\FileValidator;
1718
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1819

1920
abstract class FileValidatorTest extends ConstraintValidatorTestCase
2021
{
22+
use ForwardCompatTestTrait;
23+
2124
protected $path;
2225

2326
protected $file;
@@ -27,7 +30,7 @@ protected function createValidator()
2730
return new FileValidator();
2831
}
2932

30-
protected function setUp()
33+
private function doSetUp()
3134
{
3235
parent::setUp();
3336

@@ -36,7 +39,7 @@ protected function setUp()
3639
fwrite($this->file, ' ', 1);
3740
}
3841

39-
protected function tearDown()
42+
private function doTearDown()
4043
{
4144
parent::tearDown();
4245

Tests/Constraints/ImageValidatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Component\Validator\Constraints\Image;
1516
use Symfony\Component\Validator\Constraints\ImageValidator;
1617
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -20,6 +21,8 @@
2021
*/
2122
class ImageValidatorTest extends ConstraintValidatorTestCase
2223
{
24+
use ForwardCompatTestTrait;
25+
2326
protected $context;
2427

2528
/**
@@ -39,7 +42,7 @@ protected function createValidator()
3942
return new ImageValidator();
4043
}
4144

42-
protected function setUp()
45+
private function doSetUp()
4346
{
4447
parent::setUp();
4548

Tests/Constraints/TypeValidatorTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111

1212
namespace Symfony\Component\Validator\Tests\Constraints;
1313

14+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1415
use Symfony\Component\Validator\Constraints\Type;
1516
use Symfony\Component\Validator\Constraints\TypeValidator;
1617
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1718

1819
class TypeValidatorTest extends ConstraintValidatorTestCase
1920
{
21+
use ForwardCompatTestTrait;
22+
2023
protected static $file;
2124

2225
protected function createValidator()
@@ -172,7 +175,7 @@ protected function createFile()
172175
return static::$file;
173176
}
174177

175-
public static function tearDownAfterClass()
178+
private static function doTearDownAfterClass()
176179
{
177180
if (static::$file) {
178181
fclose(static::$file);

Tests/Mapping/Cache/DoctrineCacheTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
namespace Symfony\Component\Validator\Tests\Mapping\Cache;
1313

1414
use Doctrine\Common\Cache\ArrayCache;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Validator\Mapping\Cache\DoctrineCache;
1617

1718
class DoctrineCacheTest extends AbstractCacheTest
1819
{
19-
protected function setUp()
20+
use ForwardCompatTestTrait;
21+
22+
private function doSetUp()
2023
{
2124
$this->cache = new DoctrineCache(new ArrayCache());
2225
}

Tests/Mapping/Cache/Psr6CacheTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\Component\Validator\Tests\Mapping\Cache;
44

5+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
56
use Symfony\Component\Cache\Adapter\ArrayAdapter;
67
use Symfony\Component\Validator\Mapping\Cache\Psr6Cache;
78
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -11,7 +12,9 @@
1112
*/
1213
class Psr6CacheTest extends AbstractCacheTest
1314
{
14-
protected function setUp()
15+
use ForwardCompatTestTrait;
16+
17+
private function doSetUp()
1518
{
1619
$this->cache = new Psr6Cache(new ArrayAdapter());
1720
}

Tests/Mapping/ClassMetadataTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests\Mapping;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Validator\Constraint;
1617
use Symfony\Component\Validator\Constraints\Valid;
1718
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -21,19 +22,21 @@
2122

2223
class ClassMetadataTest extends TestCase
2324
{
25+
use ForwardCompatTestTrait;
26+
2427
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity';
2528
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent';
2629
const PROVIDERCLASS = 'Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderEntity';
2730
const PROVIDERCHILDCLASS = 'Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderChildEntity';
2831

2932
protected $metadata;
3033

31-
protected function setUp()
34+
private function doSetUp()
3235
{
3336
$this->metadata = new ClassMetadata(self::CLASSNAME);
3437
}
3538

36-
protected function tearDown()
39+
private function doTearDown()
3740
{
3841
$this->metadata = null;
3942
}

Tests/Mapping/Loader/StaticMethodLoaderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@
1212
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ForwardCompatTestTrait;
1516
use Symfony\Component\Validator\Mapping\ClassMetadata;
1617
use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
1718
use Symfony\Component\Validator\Tests\Fixtures\ConstraintA;
1819

1920
class StaticMethodLoaderTest extends TestCase
2021
{
22+
use ForwardCompatTestTrait;
23+
2124
private $errorLevel;
2225

23-
protected function setUp()
26+
private function doSetUp()
2427
{
2528
$this->errorLevel = error_reporting();
2629
}
2730

28-
protected function tearDown()
31+
private function doTearDown()
2932
{
3033
error_reporting($this->errorLevel);
3134
}

0 commit comments

Comments
 (0)