Annotation of embedaddon/php/ext/spl/tests/fileobject_003.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: SPL: SplFileInfo cloning
3: --FILE--
4: <?php
5:
6: function test($name, $lc, $lp)
7: {
8: static $i = 0;
9: echo "===$i===\n";
10: $i++;
11:
12: $o = new SplFileInfo($name);
13:
14: var_dump($o);
15: $c = clone $o;
16: var_dump($c);
17: var_dump($o === $c);
18: var_dump($o == $c);
19: var_dump($o->getPathname() == $c->getPathname());
20:
1.1.1.2 ! misho 21: try {
! 22: $f = new SplFileObject($name);
! 23: var_dump($name);
! 24: var_dump($f->getPathName());
! 25: $l = substr($f->getPathName(), -1);
! 26: var_dump($l != '/' && $l != '\\' && $l == $lc);
! 27: var_dump($f->getFileName());
! 28: $l = substr($f->getFileName(), -1);
! 29: var_dump($l != '/' && $l != '\\' && $l == $lc);
! 30: var_dump($f->getPath());
! 31: $l = substr($f->getPath(), -1);
! 32: var_dump($l != '/' && $l != '\\' && $l == $lp);
! 33: } catch (LogicException $e) {
! 34: echo "LogicException: ".$e->getMessage()."\n";
! 35: }
! 36: try {
! 37: $fo = $o->openFile();
! 38: var_dump($fo->getPathName(), $fo->getFileName(), $fo->getPath());
! 39: } catch (LogicException $e) {
! 40: echo "LogicException: ".$e->getMessage()."\n";
! 41: }
1.1 misho 42: }
43:
44: test(dirname(__FILE__) . '/' . 'fileobject_001a.txt', 't', substr(dirname(__FILE__),-1));
45: test(dirname(__FILE__) . '/', substr(dirname(__FILE__),-1), 'l');
46: test(dirname(__FILE__), substr(dirname(__FILE__),-1), 'l');
47:
48: ?>
49: ===DONE===
50: <?php exit(0); ?>
51: --EXPECTF--
52: ===0===
53: object(SplFileInfo)#%d (2) {
54: ["pathName":"SplFileInfo":private]=>
55: string(%d) "%s"
56: ["fileName":"SplFileInfo":private]=>
57: string(%d) "fileobject_001a.txt"
58: }
59: object(SplFileInfo)#%d (2) {
60: ["pathName":"SplFileInfo":private]=>
61: string(%d) "%s"
62: ["fileName":"SplFileInfo":private]=>
63: string(%d) "fileobject_001a.txt"
64: }
65: bool(false)
66: bool(true)
67: bool(true)
68: %s(%d) "%sfileobject_001a.txt"
69: string(%d) "%sfileobject_001a.txt"
70: bool(true)
71: string(19) "fileobject_001a.txt"
72: bool(true)
73: string(%d) "%stests"
74: bool(true)
75: string(%d) "%sfileobject_001a.txt"
76: string(19) "fileobject_001a.txt"
77: string(%d) "%stests"
78: ===1===
79: object(SplFileInfo)#%d (2) {
80: ["pathName":"SplFileInfo":private]=>
81: string(%d) "%s"
82: ["fileName":"SplFileInfo":private]=>
83: string(%d) "%s"
84: }
85: object(SplFileInfo)#%d (2) {
86: ["pathName":"SplFileInfo":private]=>
87: string(%d) "%s"
88: ["fileName":"SplFileInfo":private]=>
89: string(%d) "%s"
90: }
91: bool(false)
92: bool(true)
93: bool(true)
1.1.1.2 ! misho 94: LogicException: Cannot use SplFileObject with directories
! 95: LogicException: Cannot use SplFileObject with directories
1.1 misho 96: ===2===
97: object(SplFileInfo)#%d (2) {
98: ["pathName":"SplFileInfo":private]=>
99: string(%d) "%s"
100: ["fileName":"SplFileInfo":private]=>
101: string(%d) "%s"
102: }
103: object(SplFileInfo)#%d (2) {
104: ["pathName":"SplFileInfo":private]=>
105: string(%d) "%s"
106: ["fileName":"SplFileInfo":private]=>
107: string(%d) "%s"
108: }
109: bool(false)
110: bool(true)
111: bool(true)
1.1.1.2 ! misho 112: LogicException: Cannot use SplFileObject with directories
! 113: LogicException: Cannot use SplFileObject with directories
1.1 misho 114: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>