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 88use Doctrine \ORM \Mapping as ORM ;
99use Doctrine \ORM \Mapping \MappingException ;
1010use Doctrine \Tests \OrmTestCase ;
11-
12- use function get_parent_class ;
13- use function method_exists ;
11+ use Doctrine \Tests \PHPUnitCompatibility \ExceptionMatching ;
1412
1513class GH10449Test extends OrmTestCase
1614{
15+ use ExceptionMatching;
16+
1717 public function testToManyAssociationOnMappedSuperclassShallBeRejected (): void
1818 {
1919 $ em = $ this ->getTestEntityManager ();
@@ -25,18 +25,6 @@ public function testToManyAssociationOnMappedSuperclassShallBeRejected(): void
2525 // https://github.com/doctrine/orm/pull/10398
2626 $ em ->getClassMetadata (GH10449Entity::class);
2727 }
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- }
4028}
4129
4230/**
Original file line number Diff line number Diff line change 77use Doctrine \ORM \Mapping as ORM ;
88use Doctrine \ORM \Mapping \MappingException ;
99use Doctrine \Tests \OrmTestCase ;
10+ use Doctrine \Tests \PHPUnitCompatibility \ExceptionMatching ;
1011use Generator ;
1112
12- use function get_parent_class ;
13- use function method_exists ;
14-
1513class GH10454Test extends OrmTestCase
1614{
15+ use ExceptionMatching;
16+
1717 /**
1818 * @param class-string $className
1919 *
@@ -34,18 +34,6 @@ public function classesThatOverrideFieldNames(): Generator
3434 yield 'Entity class that redeclares a protected field inherited from a base entity ' => [GH10454EntityChildProtected::class];
3535 yield 'Entity class that redeclares a protected field inherited from a mapped superclass ' => [GH10454MappedSuperclassChildProtected::class];
3636 }
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- }
4937}
5038
5139/**
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