]> granicus.if.org Git - php/commitdiff
Directory tests: checked on PHP 5.2.6, 5.3 and 6.0 (Windows, Linux and Linux 64 bit).
authorAnt Phillips <ant@php.net>
Thu, 27 Nov 2008 14:49:14 +0000 (14:49 +0000)
committerAnt Phillips <ant@php.net>
Thu, 27 Nov 2008 14:49:14 +0000 (14:49 +0000)
ext/standard/tests/directory/DirectoryClass_basic_001.phpt [new file with mode: 0644]
ext/standard/tests/directory/DirectoryClass_error_001.phpt [new file with mode: 0644]
ext/standard/tests/directory/directory_constants-win32.phpt [new file with mode: 0644]
ext/standard/tests/directory/directory_constants.phpt [new file with mode: 0644]

diff --git a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt
new file mode 100644 (file)
index 0000000..e8ffd57
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+Directory class behaviour.
+--FILE--
+<?php
+/* 
+ * Prototype: object dir(string directory[, resource context])
+ * Description: Directory class with properties, handle and class and methods read, rewind and close
+ * Class is defined in ext/standard/dir.c
+ */
+
+echo "Structure of Directory class:\n";
+$rc = new ReflectionClass("Directory");
+echo $rc;
+
+echo "Cannot instantiate a valid Directory directly:\n";
+$d = new Directory(getcwd());
+var_dump($d);
+var_dump($d->read());
+
+?>
+--EXPECTF--
+Structure of Directory class:
+Class [ <internal%s> class Directory ] {
+
+  - Constants [0] {
+  }
+
+  - Static properties [0] {
+  }
+
+  - Static methods [0] {
+  }
+
+  - Properties [0] {
+  }
+
+  - Methods [3] {
+    Method [ <internal%s> public method close ] {
+    }
+
+    Method [ <internal%s> public method rewind ] {
+    }
+
+    Method [ <internal%s> public method read ] {
+    }
+  }
+}
+Cannot instantiate a valid Directory directly:
+object(Directory)#%d (0) {
+}
+
+Warning: Directory::read(): Unable to find my handle property in %s on line 15
+bool(false)
\ No newline at end of file
diff --git a/ext/standard/tests/directory/DirectoryClass_error_001.phpt b/ext/standard/tests/directory/DirectoryClass_error_001.phpt
new file mode 100644 (file)
index 0000000..5b2771e
--- /dev/null
@@ -0,0 +1,59 @@
+--TEST--
+Directory class behaviour.
+--FILE--
+<?php
+
+echo "\n--> Try all methods with bad handle:\n";
+$d = new Directory(getcwd());
+$d->handle = "Havoc!";
+var_dump($d->read());
+var_dump($d->rewind());
+var_dump($d->close());
+
+echo "\n--> Try all methods with no handle:\n";
+$d = new Directory(getcwd());
+unset($d->handle);
+var_dump($d->read());
+var_dump($d->rewind());
+var_dump($d->close());
+
+echo "\n--> Try all methods with wrong number of args:\n";
+$d = new Directory(getcwd());
+var_dump($d->read(1,2));
+var_dump($d->rewind(1,2));
+var_dump($d->close(1,2));
+
+?>
+--EXPECTF--
+--> Try all methods with bad handle:
+
+Warning: Directory::read(): supplied argument is not a valid Directory resource in %s on line %d
+bool(false)
+
+Warning: Directory::rewind(): supplied argument is not a valid Directory resource in %s on line %d
+bool(false)
+
+Warning: Directory::close(): supplied argument is not a valid Directory resource in %s on line %d
+bool(false)
+
+--> Try all methods with no handle:
+
+Warning: Directory::read(): Unable to find my handle property in %s on line %d
+bool(false)
+
+Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
+bool(false)
+
+Warning: Directory::close(): Unable to find my handle property in %s on line %d
+bool(false)
+
+--> Try all methods with wrong number of args:
+
+Warning: Directory::read() expects at most 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: Directory::rewind() expects at most 1 parameter, 2 given in %s on line %d
+NULL
+
+Warning: Directory::close() expects at most 1 parameter, 2 given in %s on line %d
+NULL
diff --git a/ext/standard/tests/directory/directory_constants-win32.phpt b/ext/standard/tests/directory/directory_constants-win32.phpt
new file mode 100644 (file)
index 0000000..6a9a066
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Test that the Directory extension constants are correctly defined.
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+    die('skip.. only for Windows');
+}
+?>
+--FILE--
+<?php
+
+echo DIRECTORY_SEPARATOR;
+
+echo "\n";
+
+echo PATH_SEPARATOR;
+
+echo "\n";
+
+echo "done";
+
+?>
+--EXPECT--
+\
+;
+done
diff --git a/ext/standard/tests/directory/directory_constants.phpt b/ext/standard/tests/directory/directory_constants.phpt
new file mode 100644 (file)
index 0000000..f8e143b
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+Test that the Directory extension constants are correctly defined.
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+    die('skip.. Not valid for Windows');
+}
+?>
+--FILE--
+<?php
+
+echo DIRECTORY_SEPARATOR;
+
+echo "\n";
+
+echo PATH_SEPARATOR;
+
+echo "\n";
+
+echo "done";
+
+?>
+--EXPECT--
+/
+:
+done