Skip to content

Commit cd128b7

Browse files
Merge branch '10.5' into 11.1
2 parents fa4b177 + 2359c29 commit cd128b7

File tree

9 files changed

+113
-37
lines changed

9 files changed

+113
-37
lines changed

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<testsuite name="end-to-end">
1616
<directory suffix=".phpt">tests/end-to-end/baseline</directory>
1717
<directory suffix=".phpt">tests/end-to-end/cli</directory>
18+
<directory suffix=".phpt">tests/end-to-end/data-provider</directory>
1819
<directory suffix=".phpt">tests/end-to-end/event</directory>
1920
<directory suffix=".phpt">tests/end-to-end/execution-order</directory>
2021
<directory suffix=".phpt">tests/end-to-end/extension</directory>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
use PHPUnit\Framework\Attributes\DataProvider;
13+
use PHPUnit\Framework\TestCase;
14+
15+
final class DataProviderWithStringKeysTest extends TestCase
16+
{
17+
public static function providerMethod(): array
18+
{
19+
return [
20+
'0 + 0 = 0' => [0, 0, 0],
21+
'0 + 1 = 1' => [0, 1, 1],
22+
'1 + 1 = 3' => [1, 1, 3],
23+
'1 + 0 = 1' => [1, 0, 1],
24+
];
25+
}
26+
27+
#[DataProvider('providerMethod')]
28+
public function testAdd($a, $b, $c): void
29+
{
30+
$this->assertEquals($c, $a + $b);
31+
}
32+
}

tests/_files/failure.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
failure
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
print 'failure';
6+
--EXPECT--
7+
success

tests/_files/success.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
success
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
print 'success';
6+
--EXPECT--
7+
success
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
--TEST--
2+
phpunit --log-junit php://stdout ../../_files/DataProviderTest.php
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$logfile = tempnam(sys_get_temp_dir(), __FILE__);
6+
7+
$_SERVER['argv'][] = '--do-not-cache-result';
8+
$_SERVER['argv'][] = '--no-configuration';
9+
$_SERVER['argv'][] = '--no-output';
10+
$_SERVER['argv'][] = '--log-junit';
11+
$_SERVER['argv'][] = $logfile;
12+
$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderTest.php';
13+
$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderWithStringKeysTest.php';
14+
$_SERVER['argv'][] = __DIR__ . '/../../_files/success.phpt';
15+
$_SERVER['argv'][] = __DIR__ . '/../../_files/failure.phpt';
16+
17+
require_once __DIR__ . '/../../bootstrap.php';
18+
19+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
20+
21+
print file_get_contents($logfile);
22+
23+
unlink($logfile);
24+
--EXPECTF--
25+
<?xml version="1.0" encoding="UTF-8"?>
26+
<testsuites>
27+
<testsuite name="CLI Arguments" tests="10" assertions="10" errors="0" failures="3" skipped="0" time="%s">
28+
<testsuite name="PHPUnit\TestFixture\DataProviderTest" file="%sDataProviderTest.php" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
29+
<testsuite name="PHPUnit\TestFixture\DataProviderTest::testAdd" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
30+
<testcase name="testAdd with data set #0" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s"/>
31+
<testcase name="testAdd with data set #1" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s"/>
32+
<testcase name="testAdd with data set #2" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s">
33+
<failure type="PHPUnit\Framework\ExpectationFailedException">PHPUnit\TestFixture\DataProviderTest::testAdd with data set #2%A
34+
Failed asserting that 2 matches expected 3.
35+
%A
36+
%sDataProviderTest.php:%d</failure>
37+
</testcase>
38+
<testcase name="testAdd with data set #3" file="%sDataProviderTest.php" line="%d" class="PHPUnit\TestFixture\DataProviderTest" classname="PHPUnit.TestFixture.DataProviderTest" assertions="1" time="%s"/>
39+
</testsuite>
40+
</testsuite>
41+
<testsuite name="PHPUnit\TestFixture\DataProviderWithStringKeysTest" file="%sDataProviderWithStringKeysTest.php" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
42+
<testsuite name="PHPUnit\TestFixture\DataProviderWithStringKeysTest::testAdd" tests="4" assertions="4" errors="0" failures="1" skipped="0" time="%s">
43+
<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"/>
44+
<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"/>
45+
<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">
46+
<failure type="PHPUnit\Framework\ExpectationFailedException">PHPUnit\TestFixture\DataProviderWithStringKeysTest::testAdd with data set "1 + 1 = 3"%A
47+
Failed asserting that 2 matches expected 3.
48+
%A
49+
%sDataProviderWithStringKeysTest.php:%d</failure>
50+
</testcase>
51+
<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"/>
52+
</testsuite>
53+
</testsuite>
54+
<testcase name="success.phpt" file="%ssuccess.phpt" assertions="1" time="%s"/>
55+
<testcase name="failure.phpt" file="%sfailure.phpt" assertions="1" time="%s">
56+
<failure type="PHPUnit\Framework\PhptAssertionFailedError">failure.phptFailed asserting that two strings are equal.%A
57+
--- Expected
58+
+++ Actual
59+
@@ @@
60+
-'success'
61+
+'failure'
62+
%A
63+
%s:%d</failure>
64+
</testcase>
65+
</testsuite>
66+
</testsuites>

tests/end-to-end/generic/dataprovider-log-xml.phpt

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)