@@ -96,27 +96,21 @@ public function testSingleStringWithDoubleQuotesAndEscapedQuote()
9696 $ this ->assertEquals (array ('he"llo ' ), $ args );
9797 }
9898
99- /**
100- * @expectedException Clue\Arguments\UnclosedQuotesException
101- */
10299 public function testSingleStringWithUnbalancedDoubleQuotesThrows ()
103100 {
101+ $ this ->setExpectedException ('Clue\Arguments\UnclosedQuotesException ' );
104102 Arguments \split ('"hello ' );
105103 }
106104
107- /**
108- * @expectedException Clue\Arguments\UnclosedQuotesException
109- */
110105 public function testSingleStringWithUnbalancedSingleQuotesThrows ()
111106 {
107+ $ this ->setExpectedException ('Clue\Arguments\UnclosedQuotesException ' );
112108 Arguments \split ("'hello " );
113109 }
114110
115- /**
116- * @expectedException Clue\Arguments\UnclosedQuotesException
117- */
118111 public function testSimpleStringWithUnbalancedSingleQuotesThrows ()
119112 {
113+ $ this ->setExpectedException ('Clue\Arguments\UnclosedQuotesException ' );
120114 Arguments \split ("echo let's go " );
121115 }
122116
@@ -134,11 +128,9 @@ public function testDoubleQuotedWithAppendedString()
134128 $ this ->assertEquals (array ('hello ' ), $ args );
135129 }
136130
137- /**
138- * @expectedException Clue\Arguments\UnclosedQuotesException
139- */
140131 public function testSimpleStringWithUnbalancedDoubleQuotesThrows ()
141132 {
133+ $ this ->setExpectedException ('Clue\Arguments\UnclosedQuotesException ' );
142134 Arguments \split ('hello "world ' );
143135 }
144136
@@ -316,4 +308,21 @@ public function testSingleStringWithCombinedSingleQuotedPartsWithInterpretedEsca
316308
317309 $ this ->assertEquals (array ("\n\\n \n" ), $ args );
318310 }
311+
312+ public function setExpectedException ($ exception , $ exceptionMessage = '' , $ exceptionCode = null )
313+ {
314+ if (method_exists ($ this , 'expectException ' )) {
315+ // PHPUnit 5.2+
316+ $ this ->expectException ($ exception );
317+ if ($ exceptionMessage !== '' ) {
318+ $ this ->expectExceptionMessage ($ exceptionMessage );
319+ }
320+ if ($ exceptionCode !== null ) {
321+ $ this ->expectExceptionCode ($ exceptionCode );
322+ }
323+ } else {
324+ // legacy PHPUnit 4 - PHPUnit 5.1
325+ parent ::setExpectedException ($ exception , $ exceptionMessage , $ exceptionCode );
326+ }
327+ }
319328}
0 commit comments