xref: /PHP-8.2/ext/phar/tests/phar_oo_009.phpt (revision 74859783)
1--TEST--
2Phar object: iterating via SplFileObject and reading csv
3--EXTENSIONS--
4phar
5--SKIPIF--
6<?php if (!defined('SplFileObject::READ_CSV') || !defined('SplFileObject::SKIP_EMPTY')) die('skip newer SPL version is required'); ?>
7--INI--
8phar.require_hash=0
9--FILE--
10<?php
11
12$pharconfig = 2;
13
14require_once 'files/phar_oo_test.inc';
15
16$phar = new Phar($fname);
17$phar->setInfoClass('SplFileObject');
18
19$f = $phar['a.csv'];
20$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE);
21foreach($f as $k => $v)
22{
23    echo "$k=>$v\n";
24}
25
26?>
27===CSV===
28<?php
29
30$f->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV);
31foreach($f as $k => $v)
32{
33    echo "$k=>" . join('|', $v) . "\n";
34}
35
36?>
37--CLEAN--
38<?php
39unlink(__DIR__ . '/files/phar_oo_009.phar.php');
40__halt_compiler();
41?>
42--EXPECT--
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