@@ -39,22 +39,22 @@ public function testAssertXMLMatchesXSD()
39
39
}
40
40
41
41
$ constraint ->evaluate ($ content ); // should not throw an exception
42
- $ this -> assertTrue ($ constraint ->evaluate ($ content , '' , true ));
42
+ static :: assertTrue ($ constraint ->evaluate ($ content , '' , true ));
43
43
}
44
44
45
45
public function testXMLValidConstraintBasics ()
46
46
{
47
47
$ constraint = new XmlMatchesXsd ('' );
48
- $ this -> assertSame (1 , $ constraint ->count ());
49
- $ this -> assertSame ('matches XSD ' , $ constraint ->toString ());
48
+ static :: assertSame (1 , $ constraint ->count ());
49
+ static :: assertSame ('matches XSD ' , $ constraint ->toString ());
50
50
}
51
51
52
52
public function testXMLValidConstraintFalse ()
53
53
{
54
54
$ this ->expectException (
55
55
'PHPUnit\Framework\ExpectationFailedException '
56
56
);
57
- $ this ->expectExceptionMessageRegExp (
57
+ $ this ->expectExceptionMessageRegex (
58
58
'#^Failed asserting that boolean\# matches XSD\.$# '
59
59
);
60
60
@@ -67,7 +67,7 @@ public function testXMLValidConstraintInt()
67
67
$ this ->expectException (
68
68
'PHPUnit\Framework\ExpectationFailedException '
69
69
);
70
- $ this ->expectExceptionMessageRegExp (
70
+ $ this ->expectExceptionMessageRegex (
71
71
'#^Failed asserting that integer\#1 matches XSD\.$# '
72
72
);
73
73
@@ -80,7 +80,7 @@ public function testXMLValidConstraintInvalidXML()
80
80
$ this ->expectException (
81
81
'PHPUnit\Framework\ExpectationFailedException '
82
82
);
83
- $ this ->expectExceptionMessageRegExp (
83
+ $ this ->expectExceptionMessageRegex (
84
84
'#^Failed asserting that <a></b> matches XSD.[\n]\[error \d{1,}\](?s).*\.$# '
85
85
);
86
86
@@ -93,7 +93,7 @@ public function testXMLValidConstraintNotMatchingXML()
93
93
$ this ->expectException (
94
94
'PHPUnit\Framework\ExpectationFailedException '
95
95
);
96
- $ this ->expectExceptionMessageRegExp (
96
+ $ this ->expectExceptionMessageRegex (
97
97
'#^Failed asserting that <a></a> matches XSD.[\n]\[error \d{1,}\](?s).*\.$# '
98
98
);
99
99
@@ -106,7 +106,7 @@ public function testXMLValidConstraintNull()
106
106
$ this ->expectException (
107
107
'PHPUnit\Framework\ExpectationFailedException '
108
108
);
109
- $ this ->expectExceptionMessageRegExp (
109
+ $ this ->expectExceptionMessageRegex (
110
110
'#^Failed asserting that null matches XSD\.$# '
111
111
);
112
112
@@ -119,7 +119,7 @@ public function testXMLValidConstraintObject()
119
119
$ this ->expectException (
120
120
'PHPUnit\Framework\ExpectationFailedException '
121
121
);
122
- $ this ->expectExceptionMessageRegExp (
122
+ $ this ->expectExceptionMessageRegex (
123
123
'#^Failed asserting that stdClass\# matches XSD\.$# '
124
124
);
125
125
@@ -142,4 +142,18 @@ private function getAssetsDir()
142
142
{
143
143
return __DIR__ .'/../Fixtures/XmlMatchesXsdTest/ ' ;
144
144
}
145
+
146
+ /**
147
+ * @param string $pattern
148
+ */
149
+ private function expectExceptionMessageRegex ($ pattern )
150
+ {
151
+ if (method_exists ($ this , 'expectExceptionMessageRegExp ' )) {
152
+ $ this ->expectExceptionMessageRegExp ($ pattern );
153
+ } elseif (method_exists ($ this , 'expectDeprecationMessageMatches ' )) {
154
+ $ this ->expectDeprecationMessageMatches ($ pattern );
155
+ } else {
156
+ throw new \RuntimeException ('Unknown how to match against exception message. ' );
157
+ }
158
+ }
145
159
}
0 commit comments