From 2f14f55d65b123e08c6d4ab1b94542fece1297df Mon Sep 17 00:00:00 2001 From: schlndh Date: Sat, 13 Sep 2025 19:25:35 +0200 Subject: [PATCH 1/3] add E2E test simulating running individual tests in PHPStorm --- ...provider-by-phpstorm-regex-number-key.phpt | 72 +++++++++++++++++++ ...provider-by-phpstorm-regex-string-key.phpt | 72 +++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt create mode 100644 tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt diff --git a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt new file mode 100644 index 00000000000..02b207a20a8 --- /dev/null +++ b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt @@ -0,0 +1,72 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/pull/6364 +--FILE-- + ['pipe', 'w'], + ], + $pipes, +); + +$stdout = stream_get_contents($pipes[1]); +fclose($pipes[1]); +proc_close($process); + +if (preg_match("/##teamcity\\[testStarted name='testTrue with data set #1' locationHint='([^']+)'/", $stdout, $matches) !== 1) { + echo "Failed to find locationHint.\n"; + echo $stdout; + + return 0; +} + +if (preg_match('#php_qn://[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) { + echo "Failed to parse locationHint.\n"; + echo $matches[1]; + + return 0; +} + +// Simulate how PHPStorm runs an individual numbered test case +$_SERVER['argv'][] = '--do-not-cache-result'; +$_SERVER['argv'][] = '--no-configuration'; +$_SERVER['argv'][] = '--filter'; +$_SERVER['argv'][] = '/' . preg_quote($locationHintMatches[1], '/') . '$/'; +$_SERVER['argv'][] = '--test-suffix'; +$_SERVER['argv'][] = 'DataProviderFilterTest.php'; +$_SERVER['argv'][] = __DIR__ . '/../../../_files'; +$_SERVER['argv'][] = '--teamcity'; + +require_once __DIR__ . '/../../../bootstrap.php'; +(new PHPUnit\TextUI\Application)->run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: PHP %s + +##teamcity[testCount count='1' flowId='%s'] +##teamcity[testSuiteStarted name='CLI Arguments' flowId='%d'] +##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] +##teamcity[testSuiteStarted name='testTrue' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue' flowId='%d'] +##teamcity[testStarted name='testTrue with data set #1' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue with data set #1' flowId='%d'] +##teamcity[testFinished name='testTrue with data set #1' duration='1' flowId='%d'] +##teamcity[testSuiteFinished name='testTrue' flowId='%d'] +##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] +##teamcity[testSuiteFinished name='CLI Arguments' flowId='%d'] +Time: %s, Memory: %s + +OK (1 test, 1 assertion) diff --git a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt new file mode 100644 index 00000000000..f683359032a --- /dev/null +++ b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt @@ -0,0 +1,72 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/pull/6364 +--FILE-- + ['pipe', 'w'], + ], + $pipes, +); + +$stdout = stream_get_contents($pipes[1]); +fclose($pipes[1]); +proc_close($process); + +if (preg_match("/##teamcity\\[testStarted name='testFalse with data set \"false test\"' locationHint='([^']+)'/", $stdout, $matches) !== 1) { + echo "Failed to find locationHint.\n"; + echo $stdout; + + return 0; +} + +if (preg_match('#php_qn://[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) { + echo "Failed to parse locationHint.\n"; + echo $matches[1]; + + return 0; +} + +// Simulate how PHPStorm runs an individual named test case +$_SERVER['argv'][] = '--do-not-cache-result'; +$_SERVER['argv'][] = '--no-configuration'; +$_SERVER['argv'][] = '--filter'; +$_SERVER['argv'][] = '/' . preg_quote($locationHintMatches[1], '/') . '$/'; +$_SERVER['argv'][] = '--test-suffix'; +$_SERVER['argv'][] = 'DataProviderFilterTest.php'; +$_SERVER['argv'][] = __DIR__ . '/../../../_files'; +$_SERVER['argv'][] = '--teamcity'; + +require_once __DIR__ . '/../../../bootstrap.php'; +(new PHPUnit\TextUI\Application)->run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: PHP %s + +##teamcity[testCount count='1' flowId='%s'] +##teamcity[testSuiteStarted name='CLI Arguments' flowId='%d'] +##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] +##teamcity[testSuiteStarted name='testFalse' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse' flowId='%d'] +##teamcity[testStarted name='testFalse with data set "false test"' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse with data set "false test"' flowId='%d'] +##teamcity[testFinished name='testFalse with data set "false test"' duration='%s' flowId='%d'] +##teamcity[testSuiteFinished name='testFalse' flowId='%d'] +##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] +##teamcity[testSuiteFinished name='CLI Arguments' flowId='%d'] +Time: %s, Memory: %s + +OK (1 test, 1 assertion) From 38acf09f0f97f0c3bc83590dc2a1f0029985aae7 Mon Sep 17 00:00:00 2001 From: schlndh Date: Mon, 15 Sep 2025 07:42:20 +0200 Subject: [PATCH 2/3] fix E2E phpstorm test on windows --- .../filter-dataprovider-by-phpstorm-regex-number-key.phpt | 2 +- .../filter-dataprovider-by-phpstorm-regex-string-key.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt index 02b207a20a8..0284acf1299 100644 --- a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt +++ b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt @@ -34,7 +34,7 @@ if (preg_match("/##teamcity\\[testStarted name='testTrue with data set #1' locat return 0; } -if (preg_match('#php_qn://[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) { +if (preg_match('#php_qn://(?:[A-Z]:)?[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) { echo "Failed to parse locationHint.\n"; echo $matches[1]; diff --git a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt index f683359032a..9da0f60e135 100644 --- a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt +++ b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt @@ -34,7 +34,7 @@ if (preg_match("/##teamcity\\[testStarted name='testFalse with data set \"false return 0; } -if (preg_match('#php_qn://[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) { +if (preg_match('#php_qn://(?:[A-Z]:)?[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) { echo "Failed to parse locationHint.\n"; echo $matches[1]; From cd53a3d3c1d583ff0401def07def2ab7fe5b7f8f Mon Sep 17 00:00:00 2001 From: schlndh Date: Mon, 15 Sep 2025 08:07:20 +0200 Subject: [PATCH 3/3] fix E2E phpstorm test on windows --- .../filter-dataprovider-by-phpstorm-regex-number-key.phpt | 8 ++++---- .../filter-dataprovider-by-phpstorm-regex-string-key.phpt | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt index 0284acf1299..0d0a688d861 100644 --- a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt +++ b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-number-key.phpt @@ -60,10 +60,10 @@ Runtime: PHP %s ##teamcity[testCount count='1' flowId='%s'] ##teamcity[testSuiteStarted name='CLI Arguments' flowId='%d'] -##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] -##teamcity[testSuiteStarted name='testTrue' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue' flowId='%d'] -##teamcity[testStarted name='testTrue with data set #1' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue with data set #1' flowId='%d'] -##teamcity[testFinished name='testTrue with data set #1' duration='1' flowId='%d'] +##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] +##teamcity[testSuiteStarted name='testTrue' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue' flowId='%d'] +##teamcity[testStarted name='testTrue with data set #1' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue with data set #1' flowId='%d'] +##teamcity[testFinished name='testTrue with data set #1' duration='%s' flowId='%d'] ##teamcity[testSuiteFinished name='testTrue' flowId='%d'] ##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] ##teamcity[testSuiteFinished name='CLI Arguments' flowId='%d'] diff --git a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt index 9da0f60e135..c15fce6c5da 100644 --- a/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt +++ b/tests/end-to-end/cli/filter/filter-dataprovider-by-phpstorm-regex-string-key.phpt @@ -60,9 +60,9 @@ Runtime: PHP %s ##teamcity[testCount count='1' flowId='%s'] ##teamcity[testSuiteStarted name='CLI Arguments' flowId='%d'] -##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] -##teamcity[testSuiteStarted name='testFalse' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse' flowId='%d'] -##teamcity[testStarted name='testFalse with data set "false test"' locationHint='php_qn://%s/DataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse with data set "false test"' flowId='%d'] +##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d'] +##teamcity[testSuiteStarted name='testFalse' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse' flowId='%d'] +##teamcity[testStarted name='testFalse with data set "false test"' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse with data set "false test"' flowId='%d'] ##teamcity[testFinished name='testFalse with data set "false test"' duration='%s' flowId='%d'] ##teamcity[testSuiteFinished name='testFalse' flowId='%d'] ##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d']