xref: /PHP-8.0/ext/phar/tests/phar_oo_009.phpt (revision f8d79582)
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--CLEAN--
37<?php
38unlink(__DIR__ . '/files/phar_oo_009.phar.php');
39__halt_compiler();
40?>
41--EXPECT--
420=>1,2,3
431=>2,a,b
442=>3,"c","'e'"
453=>4
464=>5,5
475=>7,777
48===CSV===
490=>1|2|3
501=>2|a|b
512=>3|c|'e'
523=>4
534=>5|5
546=>7|777
55