@@ -39,22 +39,22 @@ public function testAssertXMLMatchesXSD()
3939 }
4040
4141 $ constraint ->evaluate ($ content ); // should not throw an exception
42- $ this -> assertTrue ($ constraint ->evaluate ($ content , '' , true ));
42+ static :: assertTrue ($ constraint ->evaluate ($ content , '' , true ));
4343 }
4444
4545 public function testXMLValidConstraintBasics ()
4646 {
4747 $ 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 ());
5050 }
5151
5252 public function testXMLValidConstraintFalse ()
5353 {
5454 $ this ->expectException (
5555 'PHPUnit\Framework\ExpectationFailedException '
5656 );
57- $ this ->expectExceptionMessageRegExp (
57+ $ this ->expectExceptionMessageRegex (
5858 '#^Failed asserting that boolean\# matches XSD\.$# '
5959 );
6060
@@ -67,7 +67,7 @@ public function testXMLValidConstraintInt()
6767 $ this ->expectException (
6868 'PHPUnit\Framework\ExpectationFailedException '
6969 );
70- $ this ->expectExceptionMessageRegExp (
70+ $ this ->expectExceptionMessageRegex (
7171 '#^Failed asserting that integer\#1 matches XSD\.$# '
7272 );
7373
@@ -80,7 +80,7 @@ public function testXMLValidConstraintInvalidXML()
8080 $ this ->expectException (
8181 'PHPUnit\Framework\ExpectationFailedException '
8282 );
83- $ this ->expectExceptionMessageRegExp (
83+ $ this ->expectExceptionMessageRegex (
8484 '#^Failed asserting that <a></b> matches XSD.[\n]\[error \d{1,}\](?s).*\.$# '
8585 );
8686
@@ -93,7 +93,7 @@ public function testXMLValidConstraintNotMatchingXML()
9393 $ this ->expectException (
9494 'PHPUnit\Framework\ExpectationFailedException '
9595 );
96- $ this ->expectExceptionMessageRegExp (
96+ $ this ->expectExceptionMessageRegex (
9797 '#^Failed asserting that <a></a> matches XSD.[\n]\[error \d{1,}\](?s).*\.$# '
9898 );
9999
@@ -106,7 +106,7 @@ public function testXMLValidConstraintNull()
106106 $ this ->expectException (
107107 'PHPUnit\Framework\ExpectationFailedException '
108108 );
109- $ this ->expectExceptionMessageRegExp (
109+ $ this ->expectExceptionMessageRegex (
110110 '#^Failed asserting that null matches XSD\.$# '
111111 );
112112
@@ -119,7 +119,7 @@ public function testXMLValidConstraintObject()
119119 $ this ->expectException (
120120 'PHPUnit\Framework\ExpectationFailedException '
121121 );
122- $ this ->expectExceptionMessageRegExp (
122+ $ this ->expectExceptionMessageRegex (
123123 '#^Failed asserting that stdClass\# matches XSD\.$# '
124124 );
125125
@@ -142,4 +142,18 @@ private function getAssetsDir()
142142 {
143143 return __DIR__ .'/../Fixtures/XmlMatchesXsdTest/ ' ;
144144 }
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+ }
145159}
0 commit comments