1111namespace Brain \Monkey \Tests ;
1212
1313use Brain \Monkey ;
14- use PHPUnit \Framework \Error \Error as PHPUnit_Error ;
1514use PHPUnit \Framework \TestCase ;
1615
1716/**
@@ -49,60 +48,6 @@ protected function tearDownFixtures()
4948 $ this ->tearDownMakingSureExpectedExceptionIsThrown ();
5049 }
5150
52- /**
53- * PHPUnit cross-version support.
54- *
55- * @param string $needle
56- * @param string $haystack
57- * @param string $message
58- * @return void
59- */
60- public static function assertStringContains ($ needle , $ haystack , $ message = '' ) {
61-
62- if (method_exists (TestCase::class, 'assertStringContainsString ' )) {
63- // PHPUnit 7.5+.
64- TestCase::assertStringContainsString ($ needle , $ haystack , $ message );
65-
66- return ;
67- }
68-
69- // PHPUnit < 7.5.
70- static ::assertContains ($ needle , $ haystack , $ message );
71- }
72-
73- /**
74- * PHPUnit cross-version support.
75- */
76- protected function expectErrorException ()
77- {
78- if (method_exists ($ this , 'expectError ' )) {
79- // PHPUnit 8.4+.
80- $ this ->expectError ();
81- return ;
82- }
83-
84- // PHPUnit < 8.4.
85- $ this ->expectException (PHPUnit_Error::class);
86- }
87-
88- /**
89- * PHPUnit cross-version support.
90- *
91- * @param string $msgRegex
92- * @return void
93- */
94- protected function expectExceptionMsgRegex ($ msgRegex )
95- {
96- if (method_exists ($ this , 'expectExceptionMessageMatches ' )) {
97- // PHPUnit 8.4+.
98- $ this ->expectExceptionMessageMatches ($ msgRegex );
99- return ;
100- }
101-
102- // PHPUnit < 8.4.
103- $ this ->expectExceptionMessageRegExp ($ msgRegex );
104- }
105-
10651 /**
10752 * We can't use PHPUnit expectException() because we need to wait for `Monkey\tearDown` and that
10853 * does not work for `expectException()`.
@@ -123,13 +68,8 @@ protected function tearDownMakingSureExpectedExceptionIsThrown()
12368 $ this ->expect_mockery_exception
12469 );
12570
126- if (class_exists ('PHPUnit \\Framework \\ExpectationFailedException ' )) {
127- // PHPUnit 6.0+.
128- throw new \PHPUnit \Framework \ExpectationFailedException ($ message );
129- } else {
130- // PHPUnit 5.x.
131- throw new \PHPUnit_Framework_ExpectationFailedException ($ message );
132- }
71+ throw new \PHPUnit \Framework \ExpectationFailedException ($ message );
72+
13373 } catch (\Throwable $ e ) {
13474 if (get_class ($ e ) !== $ this ->expect_mockery_exception ) {
13575 throw $ e ;
@@ -148,13 +88,7 @@ protected function expectMockeryException($class)
14888 $ class
14989 );
15090
151- if (class_exists ('PHPUnit \\Framework \\Exception ' )) {
152- // PHPUnit 6.0+.
153- throw new \PHPUnit \Framework \Exception ($ message );
154- } else {
155- // PHPUnit 5.x.
156- throw new \PHPUnit_Framework_Exception ($ message );
157- }
91+ throw new \PHPUnit \Framework \Exception ($ message );
15892 }
15993
16094 $ this ->expect_mockery_exception = $ class ;
0 commit comments