Skip to content

Commit f7b45a5

Browse files
Clean up cleanup code
1 parent 63b09d5 commit f7b45a5

9 files changed

+37
-25
lines changed

tests/end-to-end/execution-order/cache-result.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
phpunit --order-by=no-depends,reverse --cache-result --cache-result-file ./tests/_files/MultiDependencyTest.php
33
--FILE--
44
<?php declare(strict_types=1);
5-
$target = tempnam(sys_get_temp_dir(), __FILE__);
5+
$target = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);
66

77
$arguments = [
88
'--no-configuration',
@@ -18,8 +18,6 @@ require __DIR__ . '/../../bootstrap.php';
1818
PHPUnit\TextUI\Command::main(false);
1919

2020
print file_get_contents($target);
21-
22-
unlink($target);
2321
--EXPECTF--
2422
PHPUnit %s by Sebastian Bergmann and contributors.
2523

@@ -30,3 +28,6 @@ Time: %s, Memory: %s
3028
OK, but incomplete, skipped, or risky tests!
3129
Tests: 5, Assertions: 3, Skipped: 2.
3230
C:37:"PHPUnit\Runner\DefaultTestResultCache":%d:{a:2:{s:7:"defects";a:2:{s:29:"MultiDependencyTest::testFour";i:1;s:30:"MultiDependencyTest::testThree";i:1;}s:5:"times";a:5:{s:29:"MultiDependencyTest::testFive";d:%f;s:29:"MultiDependencyTest::testFour";d:%f;s:30:"MultiDependencyTest::testThree";d:%f;s:28:"MultiDependencyTest::testTwo";d:%f;s:28:"MultiDependencyTest::testOne";d:%f;}}}
31+
--CLEAN--
32+
<?php declare(strict_types=1);
33+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

tests/end-to-end/execution-order/defects-first-order-via-cli.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
phpunit --order-by=defects ./tests/_files/MultiDependencyTest.php
33
--FILE--
44
<?php declare(strict_types=1);
5-
$tmpResultCache = \tempnam(sys_get_temp_dir(), __FILE__);
5+
$tmpResultCache = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);
6+
67
\file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/_files/MultiDependencyTest_result_cache.txt'));
78

89
$arguments = [
@@ -17,8 +18,6 @@ $arguments = [
1718

1819
require __DIR__ . '/../../bootstrap.php';
1920
PHPUnit\TextUI\Command::main();
20-
21-
\unlink($tmpResultCache);
2221
--EXPECTF--
2322
PHPUnit %s by Sebastian Bergmann and contributors.
2423

@@ -37,3 +36,6 @@ Test 'MultiDependencyTest::testFour' ended
3736
Time: %s, Memory: %s
3837

3938
OK (5 tests, 6 assertions)
39+
--CLEAN--
40+
<?php declare(strict_types=1);
41+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

tests/end-to-end/execution-order/order-by-duration-via-cli.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
phpunit --order-by=duration ./tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php
33
--FILE--
44
<?php declare(strict_types=1);
5+
$tmpResultCache = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);
56

6-
$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
77
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/_files/TestWithDifferentDurations.phpunit.result.cache.txt'));
88

99
$_SERVER['argv'][1] = '--no-configuration';
@@ -15,8 +15,6 @@ $_SERVER['argv'][6] = __DIR__ . '/_files/TestWithDifferentDurations.php';
1515

1616
require __DIR__ . '/../../bootstrap.php';
1717
PHPUnit\TextUI\Command::main();
18-
19-
unlink($tmpResultCache);
2018
--EXPECTF--
2119
PHPUnit %s by Sebastian Bergmann and contributors.
2220

@@ -31,3 +29,6 @@ Test 'TestWithDifferentDurations::testThree' ended
3129
Time: %s, Memory: %s
3230

3331
OK (3 tests, 3 assertions)
32+
--CLEAN--
33+
<?php declare(strict_types=1);
34+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

tests/end-to-end/execution-order/order-by-duration-via-phpunit-xml.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
phpunit --configuration=order-by-duration.phpunit.xml
33
--FILE--
44
<?php declare(strict_types=1);
5+
$tmpResultCache = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);
56

6-
$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
77
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/_files/TestWithDifferentDurations.phpunit.result.cache.txt'));
88

99
$phpunitXmlConfig = __DIR__ . '/_files/order-by-duration.phpunit.xml';
@@ -15,8 +15,6 @@ $_SERVER['argv'][4] = '--cache-result-file=' . $tmpResultCache;
1515

1616
require __DIR__ . '/../../bootstrap.php';
1717
PHPUnit\TextUI\Command::main();
18-
19-
unlink($tmpResultCache);
2018
--EXPECTF--
2119
PHPUnit %s by Sebastian Bergmann and contributors.
2220

@@ -31,3 +29,6 @@ Test 'TestWithDifferentDurations::testThree' ended
3129
Time: %s, Memory: %s
3230

3331
OK (3 tests, 3 assertions)
32+
--CLEAN--
33+
<?php declare(strict_types=1);
34+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

tests/end-to-end/list-tests-xml-dataprovider.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
phpunit --list-tests-xml ../../_files/DataProviderTest.php
33
--FILE--
44
<?php declare(strict_types=1);
5-
$target = tempnam(sys_get_temp_dir(), __FILE__);
5+
$target = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);
66

77
$_SERVER['argv'][1] = '--no-configuration';
88
$_SERVER['argv'][2] = '--list-tests-xml';
@@ -13,8 +13,6 @@ require __DIR__ . '/../bootstrap.php';
1313
PHPUnit\TextUI\Command::main(false);
1414

1515
print file_get_contents($target);
16-
17-
unlink($target);
1816
--EXPECTF--
1917
PHPUnit %s by Sebastian Bergmann and contributors.
2018

@@ -28,3 +26,6 @@ Wrote list of tests that would have been run to %s
2826
<testCaseMethod name="testAdd" groups="default" dataSet="#3"/>
2927
</testCaseClass>
3028
</tests>
29+
--CLEAN--
30+
<?php declare(strict_types=1);
31+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

tests/end-to-end/regression/GitHub/2448-existing-test.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ $_SERVER['argv'][2] = 'Test.php';
99

1010
require __DIR__ . '/../../../bootstrap.php';
1111
PHPUnit\TextUI\Command::main(false);
12-
13-
@unlink(__DIR__ . '/2448/.phpunit.result.cache');
1412
--EXPECTF--
1513
PHPUnit %s by Sebastian Bergmann and contributors.
1614

@@ -19,3 +17,6 @@ PHPUnit %s by Sebastian Bergmann and contributors.
1917
Time: %s, Memory: %s
2018

2119
OK (1 test, 1 assertion)
20+
--CLEAN--
21+
<?php declare(strict_types=1);
22+
unlink(__DIR__ . '/2448/.phpunit.result.cache');

tests/end-to-end/regression/GitHub/2448-not-existing-test.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ $_SERVER['argv'][2] = 'Test.php';
77

88
require __DIR__ . '/../../../bootstrap.php';
99
PHPUnit\TextUI\Command::main(false);
10-
11-
@unlink(__DIR__ . '/2448/.phpunit.result.cache');
1210
--EXPECTF--
1311
PHPUnit %s by Sebastian Bergmann and contributors.
1412

1513
Cannot open file "Test.php".
14+
--CLEAN--
15+
<?php declare(strict_types=1);
16+
unlink(__DIR__ . '/2448/.phpunit.result.cache');

tests/end-to-end/regression/GitHub/3380/issue-3380-test.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
https://github.com/sebastianbergmann/phpunit/issues/3380
33
--FILE--
44
<?php declare(strict_types=1);
5-
$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
5+
$tmpResultCache = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);
6+
67
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/../../../../_files/DataproviderExecutionOrderTest_result_cache.txt'));
78

89
$_SERVER['argv'][1] = '--no-configuration';
@@ -14,8 +15,6 @@ $_SERVER['argv'][6] = \dirname(\dirname(\dirname(__DIR__))) . '/../_files/Datapr
1415

1516
require __DIR__ . '/../../../../bootstrap.php';
1617
PHPUnit\TextUI\Command::main();
17-
18-
unlink($tmpResultCache);
1918
--EXPECTF--
2019
PHPUnit %s by Sebastian Bergmann and contributors.
2120

@@ -61,3 +60,6 @@ Dataprovider Execution Order
6160

6261
FAILURES!
6362
Tests: 8, Assertions: 8, Failures: 2.
63+
--CLEAN--
64+
<?php declare(strict_types=1);
65+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

tests/end-to-end/regression/GitHub/3396/issue-3396-test.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
https://github.com/sebastianbergmann/phpunit/issues/3396
33
--FILE--
44
<?php declare(strict_types=1);
5-
$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
5+
$tmpResultCache = sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__);;
6+
67
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/../../../../_files/DataproviderExecutionOrderTest_result_cache.txt'));
78

89
$_SERVER['argv'][1] = '--no-configuration';
@@ -14,8 +15,6 @@ $_SERVER['argv'][6] = \dirname(\dirname(\dirname(__DIR__))) . '/../_files/Datapr
1415

1516
require __DIR__ . '/../../../../bootstrap.php';
1617
PHPUnit\TextUI\Command::main();
17-
18-
unlink($tmpResultCache);
1918
--EXPECTF--
2019
PHPUnit %s by Sebastian Bergmann and contributors.
2120

@@ -53,3 +52,6 @@ Failed asserting that 2 is identical to 3.
5352

5453
FAILURES!
5554
Tests: 8, Assertions: 8, Failures: 2.
55+
--CLEAN--
56+
<?php declare(strict_types=1);
57+
unlink(sys_get_temp_dir() . DIRECTORY_SEPARATOR . sha1(__FILE__));

0 commit comments

Comments
 (0)