Skip to content

Commit 12e27a7

Browse files
author
Ant Phillips
committed
Directory tests: checked on PHP 5.2.6, 5.3 and 6.0 (Windows, Linux and Linux 64 bit).
1 parent 725640d commit 12e27a7

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Directory class behaviour.
3+
--FILE--
4+
<?php
5+
/*
6+
* Prototype: object dir(string directory[, resource context])
7+
* Description: Directory class with properties, handle and class and methods read, rewind and close
8+
* Class is defined in ext/standard/dir.c
9+
*/
10+
11+
echo "Structure of Directory class:\n";
12+
$rc = new ReflectionClass("Directory");
13+
echo $rc;
14+
15+
echo "Cannot instantiate a valid Directory directly:\n";
16+
$d = new Directory(getcwd());
17+
var_dump($d);
18+
var_dump($d->read());
19+
20+
?>
21+
--EXPECTF--
22+
Structure of Directory class:
23+
Class [ <internal%s> class Directory ] {
24+
25+
- Constants [0] {
26+
}
27+
28+
- Static properties [0] {
29+
}
30+
31+
- Static methods [0] {
32+
}
33+
34+
- Properties [0] {
35+
}
36+
37+
- Methods [3] {
38+
Method [ <internal%s> public method close ] {
39+
}
40+
41+
Method [ <internal%s> public method rewind ] {
42+
}
43+
44+
Method [ <internal%s> public method read ] {
45+
}
46+
}
47+
}
48+
Cannot instantiate a valid Directory directly:
49+
object(Directory)#%d (0) {
50+
}
51+
52+
Warning: Directory::read(): Unable to find my handle property in %s on line 15
53+
bool(false)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
--TEST--
2+
Directory class behaviour.
3+
--FILE--
4+
<?php
5+
6+
echo "\n--> Try all methods with bad handle:\n";
7+
$d = new Directory(getcwd());
8+
$d->handle = "Havoc!";
9+
var_dump($d->read());
10+
var_dump($d->rewind());
11+
var_dump($d->close());
12+
13+
echo "\n--> Try all methods with no handle:\n";
14+
$d = new Directory(getcwd());
15+
unset($d->handle);
16+
var_dump($d->read());
17+
var_dump($d->rewind());
18+
var_dump($d->close());
19+
20+
echo "\n--> Try all methods with wrong number of args:\n";
21+
$d = new Directory(getcwd());
22+
var_dump($d->read(1,2));
23+
var_dump($d->rewind(1,2));
24+
var_dump($d->close(1,2));
25+
26+
?>
27+
--EXPECTF--
28+
--> Try all methods with bad handle:
29+
30+
Warning: Directory::read(): supplied argument is not a valid Directory resource in %s on line %d
31+
bool(false)
32+
33+
Warning: Directory::rewind(): supplied argument is not a valid Directory resource in %s on line %d
34+
bool(false)
35+
36+
Warning: Directory::close(): supplied argument is not a valid Directory resource in %s on line %d
37+
bool(false)
38+
39+
--> Try all methods with no handle:
40+
41+
Warning: Directory::read(): Unable to find my handle property in %s on line %d
42+
bool(false)
43+
44+
Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
45+
bool(false)
46+
47+
Warning: Directory::close(): Unable to find my handle property in %s on line %d
48+
bool(false)
49+
50+
--> Try all methods with wrong number of args:
51+
52+
Warning: Directory::read() expects at most 1 parameter, 2 given in %s on line %d
53+
NULL
54+
55+
Warning: Directory::rewind() expects at most 1 parameter, 2 given in %s on line %d
56+
NULL
57+
58+
Warning: Directory::close() expects at most 1 parameter, 2 given in %s on line %d
59+
NULL
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Test that the Directory extension constants are correctly defined.
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) != 'WIN') {
6+
die('skip.. only for Windows');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
echo DIRECTORY_SEPARATOR;
13+
14+
echo "\n";
15+
16+
echo PATH_SEPARATOR;
17+
18+
echo "\n";
19+
20+
echo "done";
21+
22+
?>
23+
--EXPECT--
24+
\
25+
;
26+
done
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Test that the Directory extension constants are correctly defined.
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) == 'WIN') {
6+
die('skip.. Not valid for Windows');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
echo DIRECTORY_SEPARATOR;
13+
14+
echo "\n";
15+
16+
echo PATH_SEPARATOR;
17+
18+
echo "\n";
19+
20+
echo "done";
21+
22+
?>
23+
--EXPECT--
24+
/
25+
:
26+
done

0 commit comments

Comments
 (0)