22
33namespace Spatie \Snapshots \Test \Integration ;
44
5- use PHPUnit \Framework \ExpectationFailedException ;
65use PHPUnit \Framework \TestCase ;
6+ use PHPUnit \Runner \Version ;
77use PHPUnit_Framework_MockObject_MockObject ;
88use Spatie \Snapshots \MatchesSnapshots ;
99
@@ -98,7 +98,7 @@ public function it_can_mismatch_a_string_snapshot()
9898 {
9999 $ mockTrait = $ this ->getMatchesSnapshotMock ();
100100
101- $ this ->expectException (ExpectationFailedException::class );
101+ $ this ->expectFailedMatchesSnapshotTest ( );
102102
103103 $ mockTrait ->assertMatchesSnapshot ('Bar ' );
104104 }
@@ -108,7 +108,7 @@ public function it_can_mismatch_a_xml_snapshot()
108108 {
109109 $ mockTrait = $ this ->getMatchesSnapshotMock ();
110110
111- $ this ->expectException (ExpectationFailedException::class );
111+ $ this ->expectFailedMatchesSnapshotTest ( );
112112
113113 $ mockTrait ->assertMatchesXmlSnapshot ('<foo><bar>Foo</bar></foo> ' );
114114 }
@@ -118,7 +118,7 @@ public function it_can_mismatch_a_json_snapshot()
118118 {
119119 $ mockTrait = $ this ->getMatchesSnapshotMock ();
120120
121- $ this ->expectException (ExpectationFailedException::class );
121+ $ this ->expectFailedMatchesSnapshotTest ( );
122122
123123 $ mockTrait ->assertMatchesJsonSnapshot ('{"foo":"baz","bar":"baz","baz":"foo"} ' );
124124 }
@@ -174,17 +174,26 @@ public function it_can_update_a_json_snapshot()
174174 );
175175 }
176176
177- protected function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
177+ private function expectIncompleteMatchesSnapshotTest (PHPUnit_Framework_MockObject_MockObject $ matchesSnapshotMock )
178178 {
179179 $ matchesSnapshotMock
180180 ->expects ($ this ->once ())
181181 ->method ('markTestIncomplete ' );
182182 }
183183
184+ private function expectFailedMatchesSnapshotTest ()
185+ {
186+ if (class_exists ('PHPUnit\Framework\ExpectationFailedException ' )) {
187+ $ this ->expectException ('PHPUnit\Framework\ExpectationFailedException ' );
188+ } else {
189+ $ this ->expectException ('PHPUnit_Framework_ExpectationFailedException ' );
190+ }
191+ }
192+
184193 /**
185194 * @return \PHPUnit_Framework_MockObject_MockObject
186195 */
187- protected function getMatchesSnapshotMock (): PHPUnit_Framework_MockObject_MockObject
196+ private function getMatchesSnapshotMock (): PHPUnit_Framework_MockObject_MockObject
188197 {
189198 $ mockMethods = [
190199 'markTestIncomplete ' ,
0 commit comments