22
33namespace Phug \Test \DevTool ;
44
5- use PHPUnit \Framework \TestCase ;
65use Phug \DevTool \Application ;
6+ use Phug \DevTool \TestCase ;
77use RuntimeException ;
88use Symfony \Component \Console \Application as ConsoleApplication ;
99use Symfony \Component \Console \Input \StringInput ;
@@ -106,19 +106,20 @@ public function testRunVendorCommand()
106106 }
107107
108108 /**
109- * @covers ::getShellCommandPath
110- * @expectedException \RuntimeException
111- * @expectedExceptionMessage The given command [vendor/bin/doNotExists] was not found
109+ * @covers ::getShellCommandPath
112110 */
113111 public function testGetShellCommandPathException ()
114112 {
115- if (method_exists (self ::class, 'expectException ' )) {
116- self ::expectException (RuntimeException::class);
117- self ::expectExceptionMessage ('The given command [vendor/bin/doNotExists] was not found ' );
113+ $ message = null ;
114+
115+ try {
116+ $ app = new Application ();
117+ $ app ->runVendorCommand ('doNotExists ' );
118+ } catch (RuntimeException $ exception ) {
119+ $ message = $ exception ->getMessage ();
118120 }
119121
120- $ app = new Application ();
121- $ app ->runVendorCommand ('doNotExists ' );
122+ self ::assertSame ('The given command [vendor/bin/doNotExists] was not found ' , $ message );
122123 }
123124
124125 /**
@@ -145,7 +146,7 @@ public function testBatPath()
145146 public function testRunUnitTests ()
146147 {
147148 $ app = new Application ();
148- self ::expectOutputRegex ('/^PHPUnit/ ' );
149+ self ::expectOutputRegex ('/^PHPUnit/m ' );
149150 $ code = $ app ->runUnitTests (['--version ' ]);
150151
151152 self ::assertSame (0 , $ code );
@@ -182,8 +183,9 @@ public function testRun()
182183 $ buffer = new BufferedOutput ();
183184 $ app = new Application ();
184185 $ app ->setAutoExit (false );
186+ $ status = $ app ->run ($ input , $ buffer );
185187
186- self ::assertSame ( 0 , $ app -> run ( $ input , $ buffer ) );
188+ self ::assertTrue ( $ status === 0 || $ status === 255 );
187189 self ::assertSame ('Code looks great. Go on! ' , trim ($ buffer ->fetch ()));
188190 }
189191}
0 commit comments