File tree Expand file tree Collapse file tree 3 files changed +29
-30
lines changed Expand file tree Collapse file tree 3 files changed +29
-30
lines changed Original file line number Diff line number Diff line change 8
8
use Doctrine \ORM \Mapping as ORM ;
9
9
use Doctrine \ORM \Mapping \MappingException ;
10
10
use Doctrine \Tests \OrmTestCase ;
11
-
12
- use function get_parent_class ;
13
- use function method_exists ;
11
+ use Doctrine \Tests \PHPUnitCompatibility \ExceptionMatching ;
14
12
15
13
class GH10449Test extends OrmTestCase
16
14
{
15
+ use ExceptionMatching;
16
+
17
17
public function testToManyAssociationOnMappedSuperclassShallBeRejected (): void
18
18
{
19
19
$ em = $ this ->getTestEntityManager ();
@@ -25,18 +25,6 @@ public function testToManyAssociationOnMappedSuperclassShallBeRejected(): void
25
25
// https://github.com/doctrine/orm/pull/10398
26
26
$ em ->getClassMetadata (GH10449Entity::class);
27
27
}
28
-
29
- /**
30
- * Override for BC with PHPUnit <8
31
- */
32
- public function expectExceptionMessageMatches (string $ regularExpression ): void
33
- {
34
- if (method_exists (get_parent_class ($ this ), 'expectExceptionMessageMatches ' )) {
35
- parent ::expectExceptionMessageMatches ($ regularExpression );
36
- } else {
37
- parent ::expectExceptionMessageRegExp ($ regularExpression );
38
- }
39
- }
40
28
}
41
29
42
30
/**
Original file line number Diff line number Diff line change 7
7
use Doctrine \ORM \Mapping as ORM ;
8
8
use Doctrine \ORM \Mapping \MappingException ;
9
9
use Doctrine \Tests \OrmTestCase ;
10
+ use Doctrine \Tests \PHPUnitCompatibility \ExceptionMatching ;
10
11
use Generator ;
11
12
12
- use function get_parent_class ;
13
- use function method_exists ;
14
-
15
13
class GH10454Test extends OrmTestCase
16
14
{
15
+ use ExceptionMatching;
16
+
17
17
/**
18
18
* @param class-string $className
19
19
*
@@ -34,18 +34,6 @@ public function classesThatOverrideFieldNames(): Generator
34
34
yield 'Entity class that redeclares a protected field inherited from a base entity ' => [GH10454EntityChildProtected::class];
35
35
yield 'Entity class that redeclares a protected field inherited from a mapped superclass ' => [GH10454MappedSuperclassChildProtected::class];
36
36
}
37
-
38
- /**
39
- * Override for BC with PHPUnit <8
40
- */
41
- public function expectExceptionMessageMatches (string $ regularExpression ): void
42
- {
43
- if (method_exists (get_parent_class ($ this ), 'expectExceptionMessageMatches ' )) {
44
- parent ::expectExceptionMessageMatches ($ regularExpression );
45
- } else {
46
- parent ::expectExceptionMessageRegExp ($ regularExpression );
47
- }
48
- }
49
37
}
50
38
51
39
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Doctrine \Tests \PHPUnitCompatibility ;
6
+
7
+ use function get_parent_class ;
8
+ use function method_exists ;
9
+
10
+ trait ExceptionMatching
11
+ {
12
+ /**
13
+ * Override for BC with PHPUnit <8
14
+ */
15
+ public function expectExceptionMessageMatches (string $ regularExpression ): void
16
+ {
17
+ if (method_exists (get_parent_class ($ this ), 'expectExceptionMessageMatches ' )) {
18
+ parent ::expectExceptionMessageMatches ($ regularExpression );
19
+ } else {
20
+ parent ::expectExceptionMessageRegExp ($ regularExpression );
21
+ }
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments