Skip to content

Commit

Permalink
Merge branch '11.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 28, 2024
2 parents 8106e9b + cd128b7 commit f231fda
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 37 deletions.
1 change: 1 addition & 0 deletions phpunit.xml
Expand Up @@ -15,6 +15,7 @@
<testsuite name="end-to-end">
<directory suffix=".phpt">tests/end-to-end/baseline</directory>
<directory suffix=".phpt">tests/end-to-end/cli</directory>
<directory suffix=".phpt">tests/end-to-end/data-provider</directory>
<directory suffix=".phpt">tests/end-to-end/event</directory>
<directory suffix=".phpt">tests/end-to-end/execution-order</directory>
<directory suffix=".phpt">tests/end-to-end/extension</directory>
Expand Down
32 changes: 32 additions & 0 deletions tests/_files/DataProviderWithStringKeysTest.php
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class DataProviderWithStringKeysTest extends TestCase
{
public static function providerMethod(): array
{
return [
'0 + 0 = 0' => [0, 0, 0],
'0 + 1 = 1' => [0, 1, 1],
'1 + 1 = 3' => [1, 1, 3],
'1 + 0 = 1' => [1, 0, 1],
];
}

#[DataProvider('providerMethod')]
public function testAdd($a, $b, $c): void
{
$this->assertEquals($c, $a + $b);
}
}
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
66 changes: 66 additions & 0 deletions tests/end-to-end/data-provider/log-junit.phpt
@@ -0,0 +1,66 @@
--TEST--
phpunit --log-junit php://stdout ../../_files/DataProviderTest.php
--FILE--
<?php declare(strict_types=1);
$logfile = tempnam(sys_get_temp_dir(), __FILE__);

$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--no-output';
$_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';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);

print file_get_contents($logfile);

unlink($logfile);
--EXPECTF--
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<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"/>
<testcase name="testAdd with data set #1" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s"/>
<testcase name="testAdd with data set #2" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s">
<failure type="PHPUnit\Framework\ExpectationFailedException">PHPUnit\TestFixture\DataProviderTest::testAdd with data set #2%A
Failed asserting that 2 matches expected 3.
%A
%sDataProviderTest.php:%d</failure>
</testcase>
<testcase name="testAdd with data set #3" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s"/>
</testsuite>
</testsuite>
<testsuite name="PHPUnit\TestFixture\DataProviderWithStringKeysTest" file="%sDataProviderWithStringKeysTest.php" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
<testsuite name="PHPUnit\TestFixture\DataProviderWithStringKeysTest::testAdd" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
<testcase name="testAdd with data set &quot;0 + 0 = 0&quot;" file="%sDataProviderWithStringKeysTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderWithStringKeysTest" classname="PHPUnit.TestFixture.DataProviderWithStringKeysTest" assertions="1" time="%s"/>
<testcase name="testAdd with data set &quot;0 + 1 = 1&quot;" file="%sDataProviderWithStringKeysTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderWithStringKeysTest" classname="PHPUnit.TestFixture.DataProviderWithStringKeysTest" assertions="1" time="%s"/>
<testcase name="testAdd with data set &quot;1 + 1 = 3&quot;" file="%sDataProviderWithStringKeysTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderWithStringKeysTest" classname="PHPUnit.TestFixture.DataProviderWithStringKeysTest" assertions="1" time="%s">
<failure type="PHPUnit\Framework\ExpectationFailedException">PHPUnit\TestFixture\DataProviderWithStringKeysTest::testAdd with data set "1 + 1 = 3"%A
Failed asserting that 2 matches expected 3.
%A
%sDataProviderWithStringKeysTest.php:%d</failure>
</testcase>
<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>
37 changes: 0 additions & 37 deletions tests/end-to-end/generic/dataprovider-log-xml.phpt

This file was deleted.

0 comments on commit f231fda

Please sign in to comment.