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

Commit75d60f4

Browse files
committed
Inject ForwardCompatibiliy in TestCase
1 parentf1801a4 commit75d60f4

File tree

9 files changed

+242
-264
lines changed

9 files changed

+242
-264
lines changed

‎src/Symfony/Bridge/PhpUnit/ForwardCompatTestTrait.php‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,7 @@
1111

1212
namespaceSymfony\Bridge\PhpUnit;
1313

14-
usePHPUnit\Framework\TestCase;
15-
16-
// A trait to provide forward compatibility with newest PHPUnit versions
17-
18-
$r =new \ReflectionClass(TestCase::class);
19-
20-
if (\PHP_VERSION_ID <70000 || !$r->hasMethod('createMock') || !$r->getMethod('createMock')->hasReturnType()) {
21-
trait ForwardCompatTestTrait
22-
{
23-
useLegacy\ForwardCompatTestTraitForV5;
24-
}
25-
}elseif ($r->getMethod('tearDown')->hasReturnType()) {
26-
trait ForwardCompatTestTrait
27-
{
28-
useLegacy\ForwardCompatTestTraitForV8;
29-
}
30-
}else {
31-
trait ForwardCompatTestTrait
32-
{
33-
useLegacy\ForwardCompatTestTraitForV7;
34-
}
14+
trait ForwardCompatTestTrait
15+
{
16+
use SetUpTearDownTrait;
3517
}

‎src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV7.php‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

‎src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php‎renamed to ‎src/Symfony/Bridge/PhpUnit/Legacy/PolyfillAssertTrait.php‎

Lines changed: 1 addition & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -15,106 +15,12 @@
1515
usePHPUnit\Framework\Constraint\LogicalNot;
1616
usePHPUnit\Framework\Constraint\StringContains;
1717
usePHPUnit\Framework\Constraint\TraversableContains;
18-
usePHPUnit\Framework\MockObject\MockObject;
19-
usePHPUnit\Framework\TestCase;
2018

2119
/**
2220
* @internal
2321
*/
24-
traitForwardCompatTestTraitForV5
22+
traitPolyfillAssertTrait
2523
{
26-
/**
27-
* @return void
28-
*/
29-
publicstaticfunctionsetUpBeforeClass()
30-
{
31-
self::doSetUpBeforeClass();
32-
}
33-
34-
/**
35-
* @return void
36-
*/
37-
publicstaticfunctiontearDownAfterClass()
38-
{
39-
self::doTearDownAfterClass();
40-
}
41-
42-
/**
43-
* @return void
44-
*/
45-
protectedfunctionsetUp()
46-
{
47-
self::doSetUp();
48-
}
49-
50-
/**
51-
* @return void
52-
*/
53-
protectedfunctiontearDown()
54-
{
55-
self::doTearDown();
56-
}
57-
58-
privatestaticfunctiondoSetUpBeforeClass()
59-
{
60-
parent::setUpBeforeClass();
61-
}
62-
63-
privatestaticfunctiondoTearDownAfterClass()
64-
{
65-
parent::tearDownAfterClass();
66-
}
67-
68-
privatefunctiondoSetUp()
69-
{
70-
parent::setUp();
71-
}
72-
73-
privatefunctiondoTearDown()
74-
{
75-
parent::tearDown();
76-
}
77-
78-
/**
79-
* @param string|string[] $originalClassName
80-
*
81-
* @return MockObject
82-
*/
83-
protectedfunctioncreateMock($originalClassName)
84-
{
85-
$mock =$this->getMockBuilder($originalClassName)
86-
->disableOriginalConstructor()
87-
->disableOriginalClone()
88-
->disableArgumentCloning();
89-
90-
if (method_exists($mock,'disallowMockingUnknownTypes')) {
91-
$mock =$mock->disallowMockingUnknownTypes();
92-
}
93-
94-
return$mock->getMock();
95-
}
96-
97-
/**
98-
* @param string|string[] $originalClassName
99-
* @param string[] $methods
100-
*
101-
* @return MockObject
102-
*/
103-
protectedfunctioncreatePartialMock($originalClassName,array$methods)
104-
{
105-
$mock =$this->getMockBuilder($originalClassName)
106-
->disableOriginalConstructor()
107-
->disableOriginalClone()
108-
->disableArgumentCloning()
109-
->setMethods(empty($methods) ?null :$methods);
110-
111-
if (method_exists($mock,'disallowMockingUnknownTypes')) {
112-
$mock =$mock->disallowMockingUnknownTypes();
113-
}
114-
115-
return$mock->getMock();
116-
}
117-
11824
/**
11925
* @param float $delta
12026
* @param string $message
@@ -320,12 +226,6 @@ public static function assertStringNotContainsStringIgnoringCase($needle, $hayst
320226
*/
321227
publicstaticfunctionassertFinite($actual,$message ='')
322228
{
323-
if (method_exists(TestCase::class,'assertFinite')) {
324-
parent::assertFinite($actual,$message);
325-
326-
return;
327-
}
328-
329229
static::assertInternalType('float',$actual,$message);
330230
static::assertTrue(is_finite($actual),$message ?$message :"Failed asserting that$actual is finite.");
331231
}
@@ -337,12 +237,6 @@ public static function assertFinite($actual, $message = '')
337237
*/
338238
publicstaticfunctionassertInfinite($actual,$message ='')
339239
{
340-
if (method_exists(TestCase::class,'assertInfinite')) {
341-
parent::assertInfinite($actual,$message);
342-
343-
return;
344-
}
345-
346240
static::assertInternalType('float',$actual,$message);
347241
static::assertTrue(is_infinite($actual),$message ?$message :"Failed asserting that$actual is infinite.");
348242
}
@@ -354,85 +248,7 @@ public static function assertInfinite($actual, $message = '')
354248
*/
355249
publicstaticfunctionassertNan($actual,$message ='')
356250
{
357-
if (method_exists(TestCase::class,'assertNan')) {
358-
parent::assertNan($actual,$message);
359-
360-
return;
361-
}
362-
363251
static::assertInternalType('float',$actual,$message);
364252
static::assertTrue(is_nan($actual),$message ?$message :"Failed asserting that$actual is nan.");
365253
}
366-
367-
/**
368-
* @param string $exception
369-
*
370-
* @return void
371-
*/
372-
publicfunctionexpectException($exception)
373-
{
374-
if (method_exists(TestCase::class,'expectException')) {
375-
parent::expectException($exception);
376-
377-
return;
378-
}
379-
380-
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedException');
381-
$property->setAccessible(true);
382-
$property->setValue($this,$exception);
383-
}
384-
385-
/**
386-
* @param int|string $code
387-
*
388-
* @return void
389-
*/
390-
publicfunctionexpectExceptionCode($code)
391-
{
392-
if (method_exists(TestCase::class,'expectExceptionCode')) {
393-
parent::expectExceptionCode($code);
394-
395-
return;
396-
}
397-
398-
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedExceptionCode');
399-
$property->setAccessible(true);
400-
$property->setValue($this,$code);
401-
}
402-
403-
/**
404-
* @param string $message
405-
*
406-
* @return void
407-
*/
408-
publicfunctionexpectExceptionMessage($message)
409-
{
410-
if (method_exists(TestCase::class,'expectExceptionMessage')) {
411-
parent::expectExceptionMessage($message);
412-
413-
return;
414-
}
415-
416-
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedExceptionMessage');
417-
$property->setAccessible(true);
418-
$property->setValue($this,$message);
419-
}
420-
421-
/**
422-
* @param string $messageRegExp
423-
*
424-
* @return void
425-
*/
426-
publicfunctionexpectExceptionMessageRegExp($messageRegExp)
427-
{
428-
if (method_exists(TestCase::class,'expectExceptionMessageRegExp')) {
429-
parent::expectExceptionMessageRegExp($messageRegExp);
430-
431-
return;
432-
}
433-
434-
$property =new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ?'PHPUnit_Framework_TestCase' : TestCase::class,'expectedExceptionMessageRegExp');
435-
$property->setAccessible(true);
436-
$property->setValue($this,$messageRegExp);
437-
}
438254
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp