--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);
}
--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);
}
?>
--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"
}
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>
#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
#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
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>
--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());
}
}
--CLEAN--
<?php
$dir = __DIR__ . '/bug68825';
-unlink("$dir/foo");
+unlink($dir . '/bug.phpt');
rmdir($dir);
?>
?>
===DONE===
---EXPECT--
+--EXPECTF--
int(0)
-string(2) "0
+string(%d) "0
"
int(0)
-string(2) "0
+string(%d) "0
"
int(0)
int(1)
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";