Browse Source

Directory tests: checked on PHP 5.2.6, 5.3 and 6.0 (Windows, Linux and Linux 64 bit).

PHP-5.2.1RC1
Ant Phillips 17 years ago
parent
commit
39de96fa50
  1. 53
      ext/standard/tests/directory/DirectoryClass_basic_001.phpt
  2. 60
      ext/standard/tests/directory/DirectoryClass_error_001.phpt
  3. 26
      ext/standard/tests/directory/directory_constants-win32.phpt
  4. 26
      ext/standard/tests/directory/directory_constants.phpt

53
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)

60
ext/standard/tests/directory/DirectoryClass_error_001.phpt

@ -0,0 +1,60 @@
--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 6
bool(false)
Warning: Directory::rewind(): supplied argument is not a valid Directory resource in %s on line 7
bool(false)
Warning: Directory::close(): supplied argument is not a valid Directory resource in %s on line 8
bool(false)
--> Try all methods with no handle:
Warning: Directory::read(): Unable to find my handle property in %s on line 13
bool(false)
Warning: Directory::rewind(): Unable to find my handle property in %s on line 14
bool(false)
Warning: Directory::close(): Unable to find my handle property in %s on line 15
bool(false)
--> Try all methods with wrong number of args:
Warning: Wrong parameter count for Directory::read() in %s on line 19
NULL
Warning: Wrong parameter count for Directory::rewind() in %s on line 20
NULL
Warning: Wrong parameter count for Directory::close() in %s on line 21
NULL

26
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

26
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
Loading…
Cancel
Save