@@ -33,14 +33,9 @@ public function testAddingNonStringMessageResultsInException($message)
3333 {
3434 $ exception = 'InvalidArgumentException ' ;
3535 $ exceptionMsg = 'The $message should be of type string. Received: ' ;
36- if (method_exists ($ this , 'expectException ' ) === true ) {
37- // PHPUnit 5+.
38- $ this ->expectException ($ exception );
39- $ this ->expectExceptionMessage ($ exceptionMsg );
40- } else {
41- // PHPUnit 4.
42- $ this ->setExpectedException ($ exception , $ exceptionMsg );
43- }
36+
37+ $ this ->expectException ($ exception );
38+ $ this ->expectExceptionMessage ($ exceptionMsg );
4439
4540 $ msgCollector = new MessageCollector ();
4641 $ msgCollector ->add ($ message );
@@ -80,14 +75,9 @@ public function testAddingMessageWithUnsupportedMessageTypeResultsInException($t
8075 {
8176 $ exception = 'InvalidArgumentException ' ;
8277 $ exceptionMsg = 'The message $type should be one of the predefined MessageCollector constants. Received: ' ;
83- if (method_exists ($ this , 'expectException ' ) === true ) {
84- // PHPUnit 5+.
85- $ this ->expectException ($ exception );
86- $ this ->expectExceptionMessage ($ exceptionMsg );
87- } else {
88- // PHPUnit 4.
89- $ this ->setExpectedException ($ exception , $ exceptionMsg );
90- }
78+
79+ $ this ->expectException ($ exception );
80+ $ this ->expectExceptionMessage ($ exceptionMsg );
9181
9282 $ msgCollector = new MessageCollector ();
9383 $ msgCollector ->add ('Message ' , $ type );
@@ -309,14 +299,9 @@ public static function dataDisplayingNonBlockingMessages()
309299 public function testDisplayingBlockingErrors ($ messages , $ expected )
310300 {
311301 $ exception = 'PHP_CodeSniffer\Exceptions\RuntimeException ' ;
312- if (method_exists ($ this , 'expectException ' ) === true ) {
313- // PHPUnit 5+.
314- $ this ->expectException ($ exception );
315- $ this ->expectExceptionMessage ($ expected );
316- } else {
317- // PHPUnit 4.
318- $ this ->setExpectedException ($ exception , $ expected );
319- }
302+
303+ $ this ->expectException ($ exception );
304+ $ this ->expectExceptionMessage ($ expected );
320305
321306 $ msgCollector = new MessageCollector ();
322307 $ this ->createErrorCache ($ msgCollector , $ messages );
0 commit comments