php-src/ext/standard/tests/file/file_variation5-win32.phpt
Christoph M. Becker 0aa1fdf28d
Fix variation5-win32(-mb).phpt wrt. parallel test execution
Each test should use its own temporary filenames to avoid issues when
the tests are executed in parallel[1].  We also silence the `unlink()`
calls in the CLEAN section just in case.

And while we're at it, we also remove the erroneous comment; there is
no symlinking involved for the Windows test variants.

[1] <https://github.com/php/php-src/pull/10175#issuecomment-1366809933>

Closes GH-10189.
2022-12-30 17:47:58 +01:00

78 lines
1.4 KiB
PHP

--TEST--
file() with various paths
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') {
die('skip windows only test');
}
?>
--FILE--
<?php
$script_directory = __DIR__;
chdir($script_directory);
$test_dirname = basename(__FILE__, ".php") . "testdir";
mkdir($test_dirname);
$filepath = __DIR__ . '/file_variation_5.tmp';
$filename = basename($filepath);
$fd = fopen($filepath, "w+");
fwrite($fd, "Line 1\nLine 2\nLine 3");
fclose($fd);
echo "file() on a path containing .. and .\n";
var_dump(file("./$test_dirname/../$filename"));
echo "\nfile() on a path containing .. with invalid directories\n";
var_dump(file("./$test_dirname/bad_dir/../../$filename"));
echo "\nfile() on a relative path from a different working directory\n";
chdir($test_dirname);
var_dump(file("../$filename"));
chdir($script_directory);
?>
--CLEAN--
<?php
$test_dirname = __DIR__ . '/' . basename(__FILE__, ".clean.php") . "testdir";
$filepath = __DIR__ . '/file_variation_5.tmp';
@unlink($filepath);
rmdir($test_dirname);
?>
--EXPECT--
file() on a path containing .. and .
array(3) {
[0]=>
string(7) "Line 1
"
[1]=>
string(7) "Line 2
"
[2]=>
string(6) "Line 3"
}
file() on a path containing .. with invalid directories
array(3) {
[0]=>
string(7) "Line 1
"
[1]=>
string(7) "Line 2
"
[2]=>
string(6) "Line 3"
}
file() on a relative path from a different working directory
array(3) {
[0]=>
string(7) "Line 1
"
[1]=>
string(7) "Line 2
"
[2]=>
string(6) "Line 3"
}