File tree Expand file tree Collapse file tree 5 files changed +117
-2
lines changed Expand file tree Collapse file tree 5 files changed +117
-2
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+
3+ <phpunit backupGlobals =" false"
4+ backupStaticAttributes =" false"
5+ colors =" true"
6+ convertErrorsToExceptions =" true"
7+ convertNoticesToExceptions =" true"
8+ convertWarningsToExceptions =" true"
9+ processIsolation =" false"
10+ stopOnFailure =" false"
11+ bootstrap =" vendor/autoload.php"
12+ >
13+ <testsuites >
14+ <testsuite name =" Github Actions printer for PHPUnit Test Suite" >
15+ <directory suffix =" .phpt" >./test/</directory >
16+ </testsuite >
17+ </testsuites >
18+ <filter >
19+ <whitelist >
20+ <directory >./src</directory >
21+ </whitelist >
22+ </filter >
23+ </phpunit >
Original file line number Diff line number Diff line change @@ -40,8 +40,12 @@ protected function printDefectTrace(TestFailure $defect): void
4040 {
4141 $ e = $ defect ->thrownException ();
4242
43- $ firstError = explode (PHP_EOL , (string )$ e )[2 ];
44- list ($ path , $ line ) = explode (": " , $ firstError );
43+ $ errorLines = array_filter (
44+ explode (PHP_EOL , (string )$ e ),
45+ function ($ l ){ return $ l ; }
46+ );
47+
48+ list ($ path , $ line ) = explode (": " , end ($ errorLines ));
4549
4650 if (!$ path ) {
4751 list ($ path , $ line ) = $ this ->getReflectionFromTest ($ defect ->getTestName ());
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class PrinterStatesTest extends PHPUnit \Framework \TestCase
4+ {
5+ public function testSuccess ()
6+ {
7+ $ this ->assertTrue (true );
8+ }
9+
10+ public function testFailure ()
11+ {
12+ $ this ->assertTrue (false );
13+ }
14+
15+ public function testError ()
16+ {
17+ strpos ();
18+ }
19+
20+ public function testMissing ()
21+ {
22+ $ this ->isMissing ();
23+ }
24+
25+ public function testSkipped ()
26+ {
27+ $ this ->markTestSkipped ('Skipped ' );
28+ }
29+
30+ public function testWarning ()
31+ {
32+ throw new PHPUnit \Framework \Warning ("This is a test warning " );
33+ }
34+
35+ public function testRisky ()
36+ {
37+ throw new PHPUnit \Framework \RiskyTestError ("This is a risky test " );
38+ }
39+
40+ public function testNoAssertions ()
41+ {
42+ }
43+
44+ public function testIncomplete ()
45+ {
46+ $ this ->markTestIncomplete ('Incomplete ' );
47+ }
48+ }
49+
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+
3+ <phpunit backupGlobals =" false"
4+ backupStaticAttributes =" false"
5+ colors =" true"
6+ convertErrorsToExceptions =" true"
7+ convertNoticesToExceptions =" true"
8+ convertWarningsToExceptions =" true"
9+ printerFile =" ../../src/Printer.php"
10+ printerClass =" mheap\GithubActionsReporter\Printer"
11+ processIsolation =" false"
12+ stopOnFailure =" false"
13+ bootstrap =" ../../vendor/autoload.php"
14+ >
15+
16+ </phpunit >
Original file line number Diff line number Diff line change 1+ --TEST--
2+ phpunit -c tests/_files/phpunit.xml tests/_files/PrinterStatesTest.php
3+ --FILE--
4+ <?php
5+ $ _SERVER ['TERM ' ] = 'xterm ' ;
6+ $ _SERVER ['argv ' ][1 ] = '-c ' ;
7+ $ _SERVER ['argv ' ][2 ] = dirname (__FILE__ ).'/_files/phpunit.xml ' ;
8+ $ _SERVER ['argv ' ][3 ] = '--colors=always ' ;
9+ $ _SERVER ['argv ' ][4 ] = dirname (__FILE__ ).'/_files/PrinterStatesTest.php ' ;
10+
11+ require_once (dirname (dirname (__FILE__ ))).'/vendor/autoload.php ' ;
12+
13+ PHPUnit \TextUI \Command::main ();
14+ ?>
15+ --EXPECTF--
16+ PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
17+
18+ ::error file=test/_files/PrinterStatesTest.php,line=17::strpos() expects at least 2 parameters, 0 given
19+ ::error file=test/_files/PrinterStatesTest.php,line=22::Call to undefined method PrinterStatesTest::isMissing()
20+ ::warning file=test/_files/PrinterStatesTest.php,line=32::This is a test warning
21+ ::error file=test/_files/PrinterStatesTest.php,line=12::Failed asserting that false is true.
22+ ::warning file=test/_files/PrinterStatesTest.php,line=37::This is a risky test
23+ ::warning file=test/_files/PrinterStatesTest.php,line=40::This test did not perform any assertions
You can’t perform that action at this time.
0 commit comments