Skip to content

Commit 3be2b0d

Browse files
authored
Add CLEAN section to some IO tests (#10081)
* Add CLEAN sections to file_(get|put)_contents() tests * Add CLEAN sections to file() tests
1 parent e36c600 commit 3be2b0d

25 files changed

+202
-55
lines changed

ext/standard/tests/file/file_get_contents_basic.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ echo "\n-- Testing with empty file --\n";
2121

2222
create_files($file_path, 1, "empty", 0755, 100, "w", "file", 1, "byte");
2323
var_dump( file_get_contents($file_path."/file1.tmp") );
24-
delete_files($file_path, 1);
2524

2625
echo "\n*** Done ***";
2726
?>
27+
--CLEAN--
28+
<?php
29+
$file_path = __DIR__;
30+
include($file_path."/file.inc");
31+
delete_files($file_path, 1);
32+
?>
2833
--EXPECT--
2934
*** Testing the basic functionality of the file_get_contents() function ***
3035
-- Testing with simple valid data file --

ext/standard/tests/file/file_get_contents_variation1.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ set_include_path($newpath);
2323
runtest();
2424
teardown_include_path();
2525
chdir("..");
26-
rmdir($thisTestDir);
2726

2827

2928
function runtest() {
@@ -36,6 +35,12 @@ function runtest() {
3635
unlink($secondFile);
3736
}
3837

38+
?>
39+
--CLEAN--
40+
<?php
41+
// TODO Clean up tmp files
42+
$thisTestDir = "fileGetContentsVar1.dir";
43+
rmdir($thisTestDir);
3944
?>
4045
--EXPECT--
4146
*** Testing file_get_contents() : variation ***

ext/standard/tests/file/file_get_contents_variation2.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ set_include_path($newpath);
2424
runtest();
2525
teardown_include_path();
2626
chdir("..");
27-
rmdir($thisTestDir);
2827

2928

3029
function runtest() {
@@ -37,6 +36,12 @@ function runtest() {
3736
unlink($scriptLocFile);
3837
}
3938

39+
?>
40+
--CLEAN--
41+
<?php
42+
$thisTestDir = "FileGetContentsVar2.dir";
43+
// TODO Clean up tmp files?
44+
rmdir($thisTestDir);
4045
?>
4146
--EXPECT--
4247
*** Testing file_get_contents() : variation ***

ext/standard/tests/file/file_get_contents_variation7-win32-mb.phpt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,22 @@ for($i = 0; $i<count($allDirs); $i++) {
5454
var_dump(file_get_contents($dir."\\".$filename));
5555
}
5656

57-
unlink($absFile);
5857
chdir($old_dir_path);
59-
rmdir($absSubDir);
60-
rmdir($absMainDir);
6158

6259
echo "\n*** Done ***\n";
6360
?>
61+
--CLEAN--
62+
<?php
63+
$mainDir = "fileGetContentsVar7私はガラスを食べられます.dir";
64+
$subDir = "fileGetContentsVar7Sub私はガラスを食べられます";
65+
$absMainDir = __DIR__."/".$mainDir;
66+
$absSubDir = $absMainDir."/".$subDir;
67+
$filename = 'FileGetContentsVar7.tmp';
68+
$absFile = $absSubDir.'/'.$filename;
69+
unlink($absFile);
70+
rmdir($absSubDir);
71+
rmdir($absMainDir);
72+
?>
6473
--EXPECTF--
6574
*** Testing file_get_contents() : variation ***
6675

ext/standard/tests/file/file_get_contents_variation7-win32.phpt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,22 @@ for($i = 0; $i<count($allDirs); $i++) {
5454
var_dump(file_get_contents($dir."\\".$filename));
5555
}
5656

57-
unlink($absFile);
5857
chdir($old_dir_path);
59-
rmdir($absSubDir);
60-
rmdir($absMainDir);
6158

6259
echo "\n*** Done ***\n";
6360
?>
61+
--CLEAN--
62+
<?php
63+
$mainDir = "fileGetContentsVar7.dir";
64+
$subDir = "fileGetContentsVar7Sub";
65+
$absMainDir = __DIR__."/".$mainDir;
66+
$absSubDir = $absMainDir."/".$subDir;
67+
$filename = 'FileGetContentsVar7.tmp';
68+
$absFile = $absSubDir.'/'.$filename;
69+
unlink($absFile);
70+
rmdir($absSubDir);
71+
rmdir($absMainDir);
72+
?>
6473
--EXPECTF--
6574
*** Testing file_get_contents() : variation ***
6675

ext/standard/tests/file/file_get_contents_variation7.phpt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,20 @@ for($i = 0; $i<count($allDirs); $i++) {
4747
}
4848

4949
chdir($old_dir_path);
50+
51+
echo "\n*** Done ***\n";
52+
?>
53+
--CLEAN--
54+
<?php
55+
$mainDir = "fileGetContentsVar7.dir";
56+
$subDir = "fileGetContentsVar7Sub";
57+
$absMainDir = __DIR__."/".$mainDir;
58+
$absSubDir = $absMainDir."/".$subDir;
59+
$filename = 'FileGetContentsVar7.tmp';
60+
$absFile = $absSubDir.'/'.$filename;
5061
unlink($absFile);
5162
rmdir($absSubDir);
5263
rmdir($absMainDir);
53-
54-
echo "\n*** Done ***\n";
5564
?>
5665
--EXPECTF--
5766
*** Testing file_get_contents() : variation ***

ext/standard/tests/file/file_get_contents_variation9.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ var_dump(file_get_contents($chainlink));
3333
var_dump(file_get_contents($softlink));
3434
var_dump(file_get_contents($hardlink));
3535

36+
echo "\n*** Done ***\n";
37+
?>
38+
--CLEAN--
39+
<?php
40+
$filename = __DIR__.'/fileGetContentsVar9.tmp';
41+
$softlink = __DIR__.'/fileGetContentsVar9.SoftLink';
42+
$hardlink = __DIR__.'/fileGetContentsVar9.HardLink';
43+
$chainlink = __DIR__.'/fileGetContentsVar9.ChainLink';
3644
unlink($chainlink);
3745
unlink($softlink);
3846
unlink($hardlink);
3947
unlink($filename);
40-
41-
echo "\n*** Done ***\n";
4248
?>
4349
--EXPECT--
4450
*** Testing file_get_contents() : variation ***

ext/standard/tests/file/file_put_contents.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ try {
2525
echo $e->getMessage(), "\n";
2626
}
2727

28-
@unlink($file);
29-
3028
echo "Done\n";
3129
?>
30+
--CLEAN--
31+
<?php
32+
$file = __DIR__."/file_put_contents.txt";
33+
unlink($file);
34+
?>
3235
--EXPECT--
3336
file_put_contents(): supplied resource is not a valid stream resource
3437
bool(false)

ext/standard/tests/file/file_put_contents_variation1.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ file_put_contents($filename, $data);
2121
echo filesize($filename)."\n";
2222
readfile($filename);
2323
echo "\n";
24-
unlink($filename);
2524

2625

26+
?>
27+
--CLEAN--
28+
<?php
29+
$filename = "FilePutContentsVar1.tmp";
30+
unlink($filename);
2731
?>
2832
--EXPECT--
2933
*** Testing file_put_contents() : variation ***

ext/standard/tests/file/file_put_contents_variation2.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ foreach($inputs as $key =>$value) {
100100
file_put_contents($filename, $value);
101101
readfile($filename);
102102
};
103-
unlink($filename);
104103

104+
?>
105+
--CLEAN--
106+
<?php
107+
$filename = __DIR__ . '/fwriteVar5.tmp';
108+
unlink($filename);
105109
?>
106110
--EXPECT--
107111
*** Testing file_put_contents() : usage variation ***

0 commit comments

Comments
 (0)