Annotation of embedaddon/php/ext/phar/tests/phar_oo_008.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar object: iterating via SplFileObject
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip"); ?>
5: <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
6: --INI--
7: phar.require_hash=0
8: --FILE--
9: <?php
10:
11: $pharconfig = 1;
12:
13: require_once 'files/phar_oo_test.inc';
14:
15: $phar = new Phar($fname);
16: $phar->setInfoClass('SplFileObject');
17:
18: $f = $phar['a.csv'];
19: echo "===1===\n";
20: foreach($f as $k => $v)
21: {
22: echo "$k=>$v\n";
23: }
24:
25: $f->setFlags(SplFileObject::DROP_NEW_LINE);
26:
27: echo "===2===\n";
28: foreach($f as $k => $v)
29: {
30: echo "$k=>$v\n";
31: }
32:
33: class MyCSVFile extends SplFileObject
34: {
35: function current()
36: {
37: return parent::fgetcsv(',', '"');
38: }
39: }
40:
41: $phar->setInfoClass('MyCSVFile');
42: $v = $phar['a.csv'];
43:
44: echo "===3===\n";
45: while(!$v->eof())
46: {
47: echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n";
48: }
49:
50: echo "===4===\n";
51: $v->rewind();
52: while(!$v->eof())
53: {
54: $l = $v->fgetcsv();
55: echo $v->key() . "=>" . join('|',$l) . "\n";
56: }
57:
58: echo "===5===\n";
59: foreach($v as $k => $d)
60: {
61: echo "$k=>" . join('|',$d) . "\n";
62: }
63:
64: class MyCSVFile2 extends SplFileObject
65: {
66: function getCurrentLine()
67: {
68: echo __METHOD__ . "\n";
69: return parent::fgetcsv(',', '"');
70: }
71: }
72:
73: $phar->setInfoClass('MyCSVFile2');
74: $v = $phar['a.csv'];
75:
76: echo "===6===\n";
77: foreach($v as $k => $d)
78: {
79: echo "$k=>" . join('|',$d) . "\n";
80: }
81:
82: ?>
83: ===DONE===
84: --CLEAN--
85: <?php
86: unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
87: __halt_compiler();
88: ?>
89: --EXPECTF--
90: ===1===
91: 0=>1,2,3
92:
93: 1=>2,a,b
94:
95: 2=>3,"c","'e'"
96: ===2===
97: 0=>1,2,3
98: 1=>2,a,b
99: 2=>3,"c","'e'"
100: ===3===
101: 0=>1|2|3
102: 0=>2|a|b
103: 1=>3|c|'e'
104: ===4===
105: 0=>1|2|3
106: 1=>2|a|b
107: 2=>3|c|'e'
108: ===5===
109: 0=>1|2|3
110: 1=>2|a|b
111: 2=>3|c|'e'
112: ===6===
113: MyCSVFile2::getCurrentLine
114: 1=>1|2|3
115: MyCSVFile2::getCurrentLine
116: 3=>2|a|b
117: MyCSVFile2::getCurrentLine
118: 5=>3|c|'e'
119: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>