Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ef254f

Browse files
committed
compatibility with phpunit8
1 parente9c8e19 commit5ef254f

File tree

5 files changed

+175
-5
lines changed

5 files changed

+175
-5
lines changed

‎src/Symfony/Component/Form/Test/FormIntegrationTestCase.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
*/
2121
abstractclass FormIntegrationTestCaseextends TestCase
2222
{
23+
use TestCaseSetUpTearDownTrait;
24+
2325
/**
2426
* @var FormFactoryInterface
2527
*/
2628
protected$factory;
2729

28-
protectedfunctionsetUp()
30+
privatefunctiondoSetUp()
2931
{
3032
$this->factory = Forms::createFormFactoryBuilder()
3133
->addExtensions($this->getExtensions())
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Form\Test;
13+
14+
usePHPUnit\Framework\TestCase;
15+
16+
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods
17+
18+
if (method_exists(\ReflectionMethod::class,'hasReturnType') && (new \ReflectionMethod(TestCase::class,'tearDown'))->hasReturnType()) {
19+
eval('
20+
namespace Symfony\Component\Form\Test;
21+
22+
/**
23+
* @internal
24+
*/
25+
trait TestCaseSetUpTearDownTrait
26+
{
27+
private function doSetUp(): void
28+
{
29+
}
30+
31+
private function doTearDown(): void
32+
{
33+
}
34+
35+
protected function setUp(): void
36+
{
37+
$this->doSetUp();
38+
}
39+
40+
protected function tearDown(): void
41+
{
42+
$this->doTearDown();
43+
}
44+
}
45+
');
46+
}else {
47+
/**
48+
* @internal
49+
*/
50+
trait TestCaseSetUpTearDownTrait
51+
{
52+
/**
53+
* @return void
54+
*/
55+
privatefunctiondoSetUp()
56+
{
57+
}
58+
59+
/**
60+
* @return void
61+
*/
62+
privatefunctiondoTearDown()
63+
{
64+
}
65+
66+
/**
67+
* @return void
68+
*/
69+
protectedfunctionsetUp()
70+
{
71+
$this->doSetUp();
72+
}
73+
74+
/**
75+
* @return void
76+
*/
77+
protectedfunctiontearDown()
78+
{
79+
$this->doTearDown();
80+
}
81+
}
82+
}

‎src/Symfony/Component/Form/Test/TypeTestCase.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
abstractclass TypeTestCaseextends FormIntegrationTestCase
1919
{
20+
use TestCaseSetUpTearDownTrait;
21+
2022
/**
2123
* @var FormBuilder
2224
*/
@@ -27,15 +29,15 @@ abstract class TypeTestCase extends FormIntegrationTestCase
2729
*/
2830
protected$dispatcher;
2931

30-
protectedfunctionsetUp()
32+
privatefunctiondoSetUp()
3133
{
3234
parent::setUp();
3335

3436
$this->dispatcher =$this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
3537
$this->builder =newFormBuilder('',null,$this->dispatcher,$this->factory);
3638
}
3739

38-
protectedfunctiontearDown()
40+
privatefunctiondoTearDown()
3941
{
4042
if (\in_array(ValidatorExtensionTrait::class,class_uses($this))) {
4143
$this->validator =null;

‎src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
abstractclass ConstraintValidatorTestCaseextends TestCase
3131
{
32+
use TestCaseSetUpTearDownTrait;
33+
3234
/**
3335
* @var ExecutionContextInterface
3436
*/
@@ -48,7 +50,7 @@ abstract class ConstraintValidatorTestCase extends TestCase
4850
protected$constraint;
4951
protected$defaultTimezone;
5052

51-
protectedfunctionsetUp()
53+
privatefunctiondoSetUp()
5254
{
5355
$this->group ='MyGroup';
5456
$this->metadata =null;
@@ -70,7 +72,7 @@ protected function setUp()
7072
$this->setDefaultTimezone('UTC');
7173
}
7274

73-
protectedfunctiontearDown()
75+
privatefunctiondoTearDown()
7476
{
7577
$this->restoreDefaultTimezone();
7678
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Validator\Test;
13+
14+
usePHPUnit\Framework\TestCase;
15+
16+
// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods
17+
18+
if (method_exists(\ReflectionMethod::class,'hasReturnType') && (new \ReflectionMethod(TestCase::class,'tearDown'))->hasReturnType()) {
19+
eval('
20+
namespace Symfony\Component\Validator\Test;
21+
22+
/**
23+
* @internal
24+
*/
25+
trait TestCaseSetUpTearDownTrait
26+
{
27+
private function doSetUp(): void
28+
{
29+
}
30+
31+
private function doTearDown(): void
32+
{
33+
}
34+
35+
protected function setUp(): void
36+
{
37+
$this->doSetUp();
38+
}
39+
40+
protected function tearDown(): void
41+
{
42+
$this->doTearDown();
43+
}
44+
}
45+
');
46+
}else {
47+
/**
48+
* @internal
49+
*/
50+
trait TestCaseSetUpTearDownTrait
51+
{
52+
/**
53+
* @return void
54+
*/
55+
privatefunctiondoSetUp()
56+
{
57+
}
58+
59+
/**
60+
* @return void
61+
*/
62+
privatefunctiondoTearDown()
63+
{
64+
}
65+
66+
/**
67+
* @return void
68+
*/
69+
protectedfunctionsetUp()
70+
{
71+
$this->doSetUp();
72+
}
73+
74+
/**
75+
* @return void
76+
*/
77+
protectedfunctiontearDown()
78+
{
79+
$this->doTearDown();
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp