Skip to content

Commit 3d69b3a

Browse files
Merge branch '10.5' into 11.5
* 10.5: fix E2E phpstorm test on windows fix E2E phpstorm test on windows add E2E test simulating running individual tests in PHPStorm
2 parents 1247f78 + 0bb6959 commit 3d69b3a

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/pull/6364
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
6+
// Simulate how PHPStorm runs a test class.
7+
$process = proc_open(
8+
[
9+
PHP_BINARY,
10+
__DIR__ . '/../../../../phpunit',
11+
'--do-not-cache-result',
12+
'--no-configuration',
13+
'--filter',
14+
'PHPUnit\\\\TestFixture\\\\DataProviderFilterTest',
15+
'--test-suffix',
16+
'DataProviderFilterTest.php',
17+
__DIR__ . '/../../../_files',
18+
'--teamcity',
19+
],
20+
[
21+
1 => ['pipe', 'w'],
22+
],
23+
$pipes,
24+
);
25+
26+
$stdout = stream_get_contents($pipes[1]);
27+
fclose($pipes[1]);
28+
proc_close($process);
29+
30+
if (preg_match("/##teamcity\\[testStarted name='testTrue with data set #1' locationHint='([^']+)'/", $stdout, $matches) !== 1) {
31+
echo "Failed to find locationHint.\n";
32+
echo $stdout;
33+
34+
return 0;
35+
}
36+
37+
if (preg_match('#php_qn://(?:[A-Z]:)?[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) {
38+
echo "Failed to parse locationHint.\n";
39+
echo $matches[1];
40+
41+
return 0;
42+
}
43+
44+
// Simulate how PHPStorm runs an individual numbered test case
45+
$_SERVER['argv'][] = '--do-not-cache-result';
46+
$_SERVER['argv'][] = '--no-configuration';
47+
$_SERVER['argv'][] = '--filter';
48+
$_SERVER['argv'][] = '/' . preg_quote($locationHintMatches[1], '/') . '$/';
49+
$_SERVER['argv'][] = '--test-suffix';
50+
$_SERVER['argv'][] = 'DataProviderFilterTest.php';
51+
$_SERVER['argv'][] = __DIR__ . '/../../../_files';
52+
$_SERVER['argv'][] = '--teamcity';
53+
54+
require_once __DIR__ . '/../../../bootstrap.php';
55+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
56+
--EXPECTF--
57+
PHPUnit %s by Sebastian Bergmann and contributors.
58+
59+
Runtime: PHP %s
60+
61+
##teamcity[testCount count='1' flowId='%s']
62+
##teamcity[testSuiteStarted name='CLI Arguments' flowId='%d']
63+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d']
64+
##teamcity[testSuiteStarted name='testTrue' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue' flowId='%d']
65+
##teamcity[testStarted name='testTrue with data set #1' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testTrue with data set #1' flowId='%d']
66+
##teamcity[testFinished name='testTrue with data set #1' duration='%s' flowId='%d']
67+
##teamcity[testSuiteFinished name='testTrue' flowId='%d']
68+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d']
69+
##teamcity[testSuiteFinished name='CLI Arguments' flowId='%d']
70+
Time: %s, Memory: %s
71+
72+
OK (1 test, 1 assertion)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/pull/6364
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
6+
// Simulate how PHPStorm runs a test class.
7+
$process = proc_open(
8+
[
9+
PHP_BINARY,
10+
__DIR__ . '/../../../../phpunit',
11+
'--do-not-cache-result',
12+
'--no-configuration',
13+
'--filter',
14+
'PHPUnit\\\\TestFixture\\\\DataProviderFilterTest',
15+
'--test-suffix',
16+
'DataProviderFilterTest.php',
17+
__DIR__ . '/../../../_files',
18+
'--teamcity',
19+
],
20+
[
21+
1 => ['pipe', 'w'],
22+
],
23+
$pipes,
24+
);
25+
26+
$stdout = stream_get_contents($pipes[1]);
27+
fclose($pipes[1]);
28+
proc_close($process);
29+
30+
if (preg_match("/##teamcity\\[testStarted name='testFalse with data set \"false test\"' locationHint='([^']+)'/", $stdout, $matches) !== 1) {
31+
echo "Failed to find locationHint.\n";
32+
echo $stdout;
33+
34+
return 0;
35+
}
36+
37+
if (preg_match('#php_qn://(?:[A-Z]:)?[^:]*::\\\\(.*)#', $matches[1], $locationHintMatches) !== 1) {
38+
echo "Failed to parse locationHint.\n";
39+
echo $matches[1];
40+
41+
return 0;
42+
}
43+
44+
// Simulate how PHPStorm runs an individual named test case
45+
$_SERVER['argv'][] = '--do-not-cache-result';
46+
$_SERVER['argv'][] = '--no-configuration';
47+
$_SERVER['argv'][] = '--filter';
48+
$_SERVER['argv'][] = '/' . preg_quote($locationHintMatches[1], '/') . '$/';
49+
$_SERVER['argv'][] = '--test-suffix';
50+
$_SERVER['argv'][] = 'DataProviderFilterTest.php';
51+
$_SERVER['argv'][] = __DIR__ . '/../../../_files';
52+
$_SERVER['argv'][] = '--teamcity';
53+
54+
require_once __DIR__ . '/../../../bootstrap.php';
55+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
56+
--EXPECTF--
57+
PHPUnit %s by Sebastian Bergmann and contributors.
58+
59+
Runtime: PHP %s
60+
61+
##teamcity[testCount count='1' flowId='%s']
62+
##teamcity[testSuiteStarted name='CLI Arguments' flowId='%d']
63+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DataProviderFilterTest' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d']
64+
##teamcity[testSuiteStarted name='testFalse' locationHint='php_qn://%sDataProviderFilterTest.php::\PHPUnit\TestFixture\DataProviderFilterTest::testFalse' flowId='%d']
65+
##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']
66+
##teamcity[testFinished name='testFalse with data set "false test"' duration='%s' flowId='%d']
67+
##teamcity[testSuiteFinished name='testFalse' flowId='%d']
68+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DataProviderFilterTest' flowId='%d']
69+
##teamcity[testSuiteFinished name='CLI Arguments' flowId='%d']
70+
Time: %s, Memory: %s
71+
72+
OK (1 test, 1 assertion)

0 commit comments

Comments
 (0)