xref: /PHP-5.4/ext/phar/tests/phar_oo_009.phpt (revision 610c7fbe)
1--TEST--
2Phar object: iterating via SplFileObject and reading csv
3--SKIPIF--
4<?php if (!extension_loaded('phar')) die('skip'); ?>
5<?php if (!defined('SplFileObject::READ_CSV') || !defined('SplFileObject::SKIP_EMPTY')) die('skip newer SPL version is required'); ?>
6--INI--
7phar.require_hash=0
8--FILE--
9<?php
10
11$pharconfig = 2;
12
13require_once 'files/phar_oo_test.inc';
14
15$phar = new Phar($fname);
16$phar->setInfoClass('SplFileObject');
17
18$f = $phar['a.csv'];
19$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
20foreach($f as $k => $v)
21{
22	echo "$k=>$v\n";
23}
24
25?>
26===CSV===
27<?php
28
29$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV);
30foreach($f as $k => $v)
31{
32	echo "$k=>" . join('|', $v) . "\n";
33}
34
35?>
36===DONE===
37--CLEAN--
38<?php
39unlink(dirname(__FILE__) . '/files/phar_oo_test.phar.php');
40__halt_compiler();
41?>
42--EXPECTF--
430=>1,2,3
441=>2,a,b
452=>3,"c","'e'"
463=>4
474=>5,5
485=>7,777
49===CSV===
500=>1|2|3
511=>2|a|b
522=>3|c|'e'
533=>4
544=>5|5
556=>7|777
56===DONE===
57