diff options
author | Ant Phillips <ant@php.net> | 2008-11-27 14:50:28 +0000 |
---|---|---|
committer | Ant Phillips <ant@php.net> | 2008-11-27 14:50:28 +0000 |
commit | 12e27a70147348db7e515e3787ce14b91c824c20 (patch) | |
tree | 4d6412cf0948743712bff887dabb012d64241cc1 | |
parent | 725640d82b666f4f37be6a59298741226e3dc8d4 (diff) | |
download | php-git-12e27a70147348db7e515e3787ce14b91c824c20.tar.gz |
Directory tests: checked on PHP 5.2.6, 5.3 and 6.0 (Windows, Linux and Linux 64 bit).
4 files changed, 164 insertions, 0 deletions
diff --git a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt new file mode 100644 index 0000000000..e8ffd5752a --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_basic_001.phpt @@ -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 index 0000000000..5b2771eef6 --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_error_001.phpt @@ -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 index 0000000000..6a9a066d64 --- /dev/null +++ b/ext/standard/tests/directory/directory_constants-win32.phpt @@ -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 index 0000000000..f8e143bc13 --- /dev/null +++ b/ext/standard/tests/directory/directory_constants.phpt @@ -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 |