Skip to content

Commit

Permalink
Also test JUnit XML logger with PHPT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 28, 2024
1 parent 6986222 commit 2359c29
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/_files/failure.phpt
@@ -0,0 +1,7 @@
--TEST--
failure
--FILE--
<?php declare(strict_types=1);
print 'failure';
--EXPECT--
success
7 changes: 7 additions & 0 deletions tests/_files/success.phpt
@@ -0,0 +1,7 @@
--TEST--
success
--FILE--
<?php declare(strict_types=1);
print 'success';
--EXPECT--
success
15 changes: 14 additions & 1 deletion tests/end-to-end/data-provider/log-junit.phpt
Expand Up @@ -11,6 +11,8 @@ $_SERVER['argv'][] = '--log-junit';
$_SERVER['argv'][] = $logfile;
$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderTest.php';
$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderWithStringKeysTest.php';
$_SERVER['argv'][] = __DIR__ . '/../../_files/success.phpt';
$_SERVER['argv'][] = __DIR__ . '/../../_files/failure.phpt';

require_once __DIR__ . '/../../bootstrap.php';

Expand All @@ -22,7 +24,7 @@ unlink($logfile);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="CLI Arguments" tests="8" assertions="8" errors="0" failures="2" skipped="0" time="%s">
<testsuite name="CLI Arguments" tests="10" assertions="10" errors="0" failures="3" skipped="0" time="%s">
<testsuite name="PHPUnit\TestFixture\DataProviderTest" file="%sDataProviderTest.php" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
<testsuite name="PHPUnit\TestFixture\DataProviderTest::testAdd" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
<testcase name="testAdd with data set #0" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s"/>
Expand All @@ -49,5 +51,16 @@ Failed asserting that 2 matches expected 3.
<testcase name="testAdd with data set &quot;1 + 0 = 1&quot;" file="%sDataProviderWithStringKeysTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderWithStringKeysTest" classname="PHPUnit.TestFixture.DataProviderWithStringKeysTest" assertions="1" time="%s"/>
</testsuite>
</testsuite>
<testcase name="success.phpt" file="%ssuccess.phpt" assertions="1" time="%s"/>
<testcase name="failure.phpt" file="%sfailure.phpt" assertions="1" time="%s">
<failure type="PHPUnit\Framework\PhptAssertionFailedError">failure.phptFailed asserting that two strings are equal.%A
--- Expected
+++ Actual
@@ @@
-'success'
+'failure'
%A
%s:%d</failure>
</testcase>
</testsuite>
</testsuites>

0 comments on commit 2359c29

Please sign in to comment.