From 172865cab57a4d17480f2f9c5e8b17dfdf2acd1e Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 28 Apr 2024 08:07:11 +0200 Subject: [PATCH 1/3] Reorganize --- phpunit.xml | 1 + .../dependency-result.phpt} | 0 .../issue-2833.phpt} | 0 .../issue-2859.phpt} | 0 .../log-junit-isolation.phpt} | 0 .../dataprovider-log-xml.phpt => data-provider/log-junit.phpt} | 0 6 files changed, 1 insertion(+) rename tests/end-to-end/{generic/dataprovider-dependency-result.phpt => data-provider/dependency-result.phpt} (100%) rename tests/end-to-end/{generic/dataprovider-issue-2833.phpt => data-provider/issue-2833.phpt} (100%) rename tests/end-to-end/{generic/dataprovider-issue-2859.phpt => data-provider/issue-2859.phpt} (100%) rename tests/end-to-end/{generic/dataprovider-log-xml-isolation.phpt => data-provider/log-junit-isolation.phpt} (100%) rename tests/end-to-end/{generic/dataprovider-log-xml.phpt => data-provider/log-junit.phpt} (100%) diff --git a/phpunit.xml b/phpunit.xml index 764fb6b12fb..8869418795d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -16,6 +16,7 @@ tests/end-to-end/baseline tests/end-to-end/cli tests/end-to-end/code-coverage + tests/end-to-end/data-provider tests/end-to-end/event tests/end-to-end/execution-order tests/end-to-end/extension diff --git a/tests/end-to-end/generic/dataprovider-dependency-result.phpt b/tests/end-to-end/data-provider/dependency-result.phpt similarity index 100% rename from tests/end-to-end/generic/dataprovider-dependency-result.phpt rename to tests/end-to-end/data-provider/dependency-result.phpt diff --git a/tests/end-to-end/generic/dataprovider-issue-2833.phpt b/tests/end-to-end/data-provider/issue-2833.phpt similarity index 100% rename from tests/end-to-end/generic/dataprovider-issue-2833.phpt rename to tests/end-to-end/data-provider/issue-2833.phpt diff --git a/tests/end-to-end/generic/dataprovider-issue-2859.phpt b/tests/end-to-end/data-provider/issue-2859.phpt similarity index 100% rename from tests/end-to-end/generic/dataprovider-issue-2859.phpt rename to tests/end-to-end/data-provider/issue-2859.phpt diff --git a/tests/end-to-end/generic/dataprovider-log-xml-isolation.phpt b/tests/end-to-end/data-provider/log-junit-isolation.phpt similarity index 100% rename from tests/end-to-end/generic/dataprovider-log-xml-isolation.phpt rename to tests/end-to-end/data-provider/log-junit-isolation.phpt diff --git a/tests/end-to-end/generic/dataprovider-log-xml.phpt b/tests/end-to-end/data-provider/log-junit.phpt similarity index 100% rename from tests/end-to-end/generic/dataprovider-log-xml.phpt rename to tests/end-to-end/data-provider/log-junit.phpt From 6986222b2e931abc7d5014011f2f2a3d68c945fd Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 28 Apr 2024 08:20:06 +0200 Subject: [PATCH 2/3] Also test JUnit XML logger with data provider that uses string keys --- .../_files/DataProviderWithStringKeysTest.php | 32 +++++++++++++++++ tests/end-to-end/data-provider/log-junit.phpt | 34 ++++++++++++++----- 2 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 tests/_files/DataProviderWithStringKeysTest.php diff --git a/tests/_files/DataProviderWithStringKeysTest.php b/tests/_files/DataProviderWithStringKeysTest.php new file mode 100644 index 00000000000..4328f243296 --- /dev/null +++ b/tests/_files/DataProviderWithStringKeysTest.php @@ -0,0 +1,32 @@ + + * + * 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); + } +} diff --git a/tests/end-to-end/data-provider/log-junit.phpt b/tests/end-to-end/data-provider/log-junit.phpt index b96ffb0cc8a..03771e52852 100644 --- a/tests/end-to-end/data-provider/log-junit.phpt +++ b/tests/end-to-end/data-provider/log-junit.phpt @@ -10,6 +10,7 @@ $_SERVER['argv'][] = '--no-output'; $_SERVER['argv'][] = '--log-junit'; $_SERVER['argv'][] = $logfile; $_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderTest.php'; +$_SERVER['argv'][] = __DIR__ . '/../../_files/DataProviderWithStringKeysTest.php'; require_once __DIR__ . '/../../bootstrap.php'; @@ -21,17 +22,32 @@ unlink($logfile); --EXPECTF-- - - - - - - PHPUnit\TestFixture\DataProviderTest::testAdd with data set #2%A + + + + + + + PHPUnit\TestFixture\DataProviderTest::testAdd with data set #2%A Failed asserting that 2 matches expected 3. %A -%s:%i - - +%sDataProviderTest.php:%d + + + + + + + + + + PHPUnit\TestFixture\DataProviderWithStringKeysTest::testAdd with data set "1 + 1 = 3"%A +Failed asserting that 2 matches expected 3. +%A +%sDataProviderWithStringKeysTest.php:%d + + + From 2359c2969e5380800ffcb4806595dc6eaf6993b7 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 28 Apr 2024 08:23:55 +0200 Subject: [PATCH 3/3] Also test JUnit XML logger with PHPT tests --- tests/_files/failure.phpt | 7 +++++++ tests/_files/success.phpt | 7 +++++++ tests/end-to-end/data-provider/log-junit.phpt | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/_files/failure.phpt create mode 100644 tests/_files/success.phpt diff --git a/tests/_files/failure.phpt b/tests/_files/failure.phpt new file mode 100644 index 00000000000..2d76d87f7ab --- /dev/null +++ b/tests/_files/failure.phpt @@ -0,0 +1,7 @@ +--TEST-- +failure +--FILE-- + - + @@ -49,5 +51,16 @@ Failed asserting that 2 matches expected 3. + + + failure.phptFailed asserting that two strings are equal.%A +--- Expected ++++ Actual +@@ @@ +-'success' ++'failure' +%A +%s:%d +