mirror of
https://github.com/php/php-src.git
synced 2026-04-29 03:03:26 +02:00
Fix some tests and improve coverage for Windows in SPL
This commit is contained in:
@@ -1,29 +1,26 @@
|
||||
--TEST--
|
||||
SPL: DirectoryIterator::getExtension() basic test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
die('skip.. only for Unix');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
|
||||
mkdir($dir);
|
||||
|
||||
$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
|
||||
if (!mkdir($dir)) {
|
||||
die('Failed to create test directory');
|
||||
}
|
||||
|
||||
$files = array('test.txt', 'test.extension', 'test');
|
||||
foreach ($files as $file) {
|
||||
touch($dir . $file);
|
||||
}
|
||||
|
||||
$dit_exts = array();
|
||||
$nfo_exts = array();
|
||||
$skip = array('.', '..');
|
||||
|
||||
foreach (new DirectoryIterator($dir) as $file) {
|
||||
if (in_array($file->getFilename(), $skip)) {
|
||||
if ($file->isDot()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dit_exts[] = $file->getExtension();
|
||||
$nfo_exts[] = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
|
||||
}
|
||||
@@ -34,7 +31,7 @@ var_dump($dit_exts);
|
||||
--CLEAN--
|
||||
<?php
|
||||
$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
|
||||
$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
|
||||
$files = array('test.txt', 'test.extension', 'test');
|
||||
foreach ($files as $file) {
|
||||
unlink($dir . $file);
|
||||
}
|
||||
@@ -42,16 +39,12 @@ rmdir($dir);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
array(5) {
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(0) ""
|
||||
[1]=>
|
||||
string(0) ""
|
||||
[2]=>
|
||||
string(0) ""
|
||||
[3]=>
|
||||
string(9) "extension"
|
||||
[4]=>
|
||||
[2]=>
|
||||
string(3) "txt"
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
SPL: DirectoryIterator test getGroup
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
|
||||
if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file groups, not available for Windows'); }
|
||||
if (!extension_loaded('posix') || posix_geteuid() == 0) { die('SKIP Cannot run test as root.'); }
|
||||
--CREDITS--
|
||||
Cesare D'Amico <cesare.damico@gruppovolta.it>
|
||||
Andrea Giorgini <agiorg@gmail.com>
|
||||
|
||||
@@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it>
|
||||
#Test Fest Cesena (Italy) on 2009-06-20
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
|
||||
if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file inodes, not available for Windows'); }
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
@@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it>
|
||||
#Test Fest Cesena (Italy) on 2009-06-20
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
|
||||
if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file inodes, not available for Windows'); }
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
SPL: DirectoryIterator test getOwner
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
|
||||
if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file ownership, not available for Windows'); }
|
||||
if (!extension_loaded('posix') || posix_geteuid() == 0) die('SKIP Cannot run test as root.');
|
||||
--CREDITS--
|
||||
Cesare D'Amico <cesare.damico@gruppovolta.it>
|
||||
Andrea Giorgini <agiorg@gmail.com>
|
||||
|
||||
@@ -3,12 +3,16 @@ Bug #68825 (Exception in DirectoryIterator::getLinkTarget())
|
||||
--FILE--
|
||||
<?php
|
||||
$dir = __DIR__ . '/bug68825';
|
||||
mkdir($dir);
|
||||
symlink(__FILE__, "$dir/foo");
|
||||
|
||||
if (!mkdir($dir)) {
|
||||
die('Failed to create temporary directory for testing');
|
||||
} else if (!symlink(__FILE__, $dir . '/bug.phpt')) {
|
||||
die('Failed to create symbolic link');
|
||||
}
|
||||
|
||||
$di = new \DirectoryIterator($dir);
|
||||
foreach ($di as $entry) {
|
||||
if ('foo' === $entry->getFilename()) {
|
||||
if ('bug' === $entry->getFilename()) {
|
||||
var_dump($entry->getLinkTarget());
|
||||
}
|
||||
}
|
||||
@@ -20,6 +24,6 @@ string(%d) "%s%eext%espl%etests%ebug68825.php"
|
||||
--CLEAN--
|
||||
<?php
|
||||
$dir = __DIR__ . '/bug68825';
|
||||
unlink("$dir/foo");
|
||||
unlink($dir . '/bug.phpt');
|
||||
rmdir($dir);
|
||||
?>
|
||||
|
||||
@@ -40,12 +40,12 @@ foreach($o as $n => $l)
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
int(0)
|
||||
string(2) "0
|
||||
string(%d) "0
|
||||
"
|
||||
int(0)
|
||||
string(2) "0
|
||||
string(%d) "0
|
||||
"
|
||||
int(0)
|
||||
int(1)
|
||||
|
||||
@@ -12,6 +12,10 @@ function test($name)
|
||||
var_dump($o->key());
|
||||
while(($c = $o->fgetc()) !== false)
|
||||
{
|
||||
// Kinda ugly but works around new lines mess
|
||||
if ($c === "\r") {
|
||||
continue;
|
||||
}
|
||||
var_dump($o->key(), $c, $o->eof());
|
||||
}
|
||||
echo "===EOF?===\n";
|
||||
|
||||
Reference in New Issue
Block a user