com php-src: Fix some tests and improve coverage for Windows in SPL: ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
ext/spl/tests/DirectoryIterator_getGroup_basic.phpt ext/spl/tests/DirectoryIterator_getInode_basic.phpt ext
/spl/tests/DirectoryIterator_getInode_error.phpt ext/sp l/tests/DirectoryIterator_getOwner_basic.phpt ext/spl/t ests/bug68825.phpt
ext/spl/tests/fileobject_0 01.phpt ext/spl/tests/fileobject_002.phpt
| From: | Kalle Sommer Nielsen | Date: | Sun, 30 Sep 2018 08:41:34 +0000 |
| Subject: | com php-src: Fix some tests and improve coverage for Windows in SPL: ext/spl/tests/DirectoryIterator_getExtension_basic.phpt ext/spl/tests/DirectoryIterator_getGroup_basic.phpt ext/spl/tests/DirectoryIterator_getInode_basic.phpt ext /spl/tests/DirectoryIterator_getInode_error.phpt ext/sp l/tests/DirectoryIterator_getOwner_basic.phpt ext/spl/t ests/bug68825.phpt ext/spl/tests/fileobject_0 01.phpt ext/spl/tests/fileobject_002.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-103276@lists.php.net to get a copy of this message | ||
Commit: 8595dc8fa93237565217e7d8d42e7e79dcd427e7
Author: Kalle Sommer Nielsen <kalle@php.net> Sun, 30 Sep 2018 10:41:34 +0200
Parents: 257bec33f82668bce0e2615bfea67bf71339d7f1
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8595dc8fa93237565217e7d8d42e7e79dcd427e7
Log:
Fix some tests and improve coverage for Windows in SPL
Changed paths:
M ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
M ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
M ext/spl/tests/DirectoryIterator_getInode_basic.phpt
M ext/spl/tests/DirectoryIterator_getInode_error.phpt
M ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
M ext/spl/tests/bug68825.phpt
M ext/spl/tests/fileobject_001.phpt
M ext/spl/tests/fileobject_002.phpt
Diff:
diff --git a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
index a35a524..e356e2a 100644
--- a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
@@ -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"
}
diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
index 81ab6c0..74586b7 100644
--- a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
@@ -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>
diff --git a/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
index a6b128a..95d2088 100644
--- a/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
@@ -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
diff --git a/ext/spl/tests/DirectoryIterator_getInode_error.phpt
b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
index 570bb21..b6a07f6 100644
--- a/ext/spl/tests/DirectoryIterator_getInode_error.phpt
+++ b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
@@ -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
diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
index 709510d..0981a7d 100644
--- a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
@@ -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>
diff --git a/ext/spl/tests/bug68825.phpt b/ext/spl/tests/bug68825.phpt
index b1ed5fb..6bc03cb 100644
--- a/ext/spl/tests/bug68825.phpt
+++ b/ext/spl/tests/bug68825..phpt
@@ -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);
?>
diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt
index 61f688d..35a5156 100644
--- a/ext/spl/tests/fileobject_001.phpt
+++ b/ext/spl/tests/fileobject_001.phpt
@@ -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)
diff --git a/ext/spl/tests/fileobject_002.phpt b/ext/spl/tests/fileobject_002.phpt
index 8031e98..1f7e4ea 100644
--- a/ext/spl/tests/fileobject_002.phpt
+++ b/ext/spl/tests/fileobject_002.phpt
@@ -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";