Annotation of embedaddon/php/ext/spl/tests/dit_002.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: SPL: DirectoryIterator defaults
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("spl") || !extension_loaded('reflection') || !defined('GLOB_ERR')) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: $classes = array(
! 9: 'DirectoryIterator' => 0,
! 10: 'FilesystemIterator' => 1,
! 11: 'RecursiveDirectoryIterator' => 1,
! 12: 'GlobIterator' => 1,
! 13: );
! 14:
! 15: foreach ($classes as $class => $flags) {
! 16: echo "===$class===\n";
! 17: $ref = new ReflectionClass($class);
! 18: $obj = $ref->newInstance('glob://*');
! 19: echo get_class($obj->current()) . "\n";
! 20: if ($flags)
! 21: {
! 22: var_dump($obj->getFlags());
! 23: $flags = array(
! 24: FilesystemIterator::CURRENT_AS_FILEINFO => 0,
! 25: FilesystemIterator::CURRENT_AS_SELF => 0,
! 26: FilesystemIterator::CURRENT_AS_PATHNAME => 1,
! 27: );
! 28: foreach($flags as $flag => $isstring) {
! 29: $obj->setFlags($flag);
! 30: $obj->rewind();
! 31: var_dump($obj->getFlags());
! 32: if ($isstring) {
! 33: $val = $obj->current();
! 34: if (is_string($val)) {
! 35: var_dump(true);
! 36: } else {
! 37: var_dump($val);
! 38: }
! 39: } else {
! 40: echo get_class($obj->current()) . "\n";
! 41: }
! 42: }
! 43: }
! 44: }
! 45: ?>
! 46: ===DONE===
! 47: --EXPECTF--
! 48: ===DirectoryIterator===
! 49: DirectoryIterator
! 50: ===FilesystemIterator===
! 51: SplFileInfo
! 52: int(%d)
! 53: int(0)
! 54: SplFileInfo
! 55: int(16)
! 56: FilesystemIterator
! 57: int(32)
! 58: bool(true)
! 59: ===RecursiveDirectoryIterator===
! 60: SplFileInfo
! 61: int(0)
! 62: int(0)
! 63: SplFileInfo
! 64: int(16)
! 65: RecursiveDirectoryIterator
! 66: int(32)
! 67: bool(true)
! 68: ===GlobIterator===
! 69: SplFileInfo
! 70: int(0)
! 71: int(0)
! 72: SplFileInfo
! 73: int(16)
! 74: GlobIterator
! 75: int(32)
! 76: bool(true)
! 77: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>