diff options
author | Marcus Boerger <helly@php.net> | 2006-03-09 20:00:47 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2006-03-09 20:00:47 +0000 |
commit | e0c9a617d52e71bdac107ce54bc77657774585ce (patch) | |
tree | 1b4bded2e6ff0f4d8523c1747058a57813a40d7b /ext/phar | |
parent | 281ebbe664a96b432c08239118d3a05149379059 (diff) | |
download | php-git-e0c9a617d52e71bdac107ce54bc77657774585ce.tar.gz |
- Add new test
Diffstat (limited to 'ext/phar')
-rwxr-xr-x | ext/phar/tests/phar_oo_008.phpt | 63 | ||||
-rwxr-xr-x | ext/phar/tests/phar_oo_test.inc | 25 |
2 files changed, 83 insertions, 5 deletions
diff --git a/ext/phar/tests/phar_oo_008.phpt b/ext/phar/tests/phar_oo_008.phpt new file mode 100755 index 0000000000..ef259b883e --- /dev/null +++ b/ext/phar/tests/phar_oo_008.phpt @@ -0,0 +1,63 @@ +--TEST-- +Phar object: iterating via SplFileObject +--SKIPIF-- +<?php if (!extension_loaded("phar")) print "skip"; ?> +--FILE-- +<?php + +$pharconfig = 1; + +require_once 'phar_oo_test.inc'; + +$phar = new Phar($fname); +$phar->setFileClass('SplFileObject'); + +$f = $phar['a.csv']; +foreach($f as $k => $v) +{ + echo "$k=>$v\n"; +} + +$f->setFlags(SplFileObject::DROP_NEW_LINE); + +foreach($f as $k => $v) +{ + echo "$k=>$v\n"; +} + +class MyCSVFile extends SplFileObject +{ + function current() + { + return parent::fgetcsv(',', '"'); + } +} + +$phar->setFileClass('MyCSVFile'); +$v = $phar['a.csv']; + +while(!$v->eof()) +{ + echo $v->key() . "=>" . join('|',$v->fgetcsv()) . "\n"; +} + +?> +===DONE=== +--CLEAN-- +<?php +unlink(dirname(__FILE__) . '/phar_oo_test.phar.php'); +__halt_compiler(); +?> +--EXPECTF-- +0=>1,2,3 + +1=>2,a,b + +2=>3,"c","'e'" +0=>1,2,3 +1=>2,a,b +2=>3,"c","'e'" +0=>1|2|3 +1=>2|a|b +2=>3|c|'e' +===DONE=== diff --git a/ext/phar/tests/phar_oo_test.inc b/ext/phar/tests/phar_oo_test.inc index fc79a18edf..786da6c3c0 100755 --- a/ext/phar/tests/phar_oo_test.inc +++ b/ext/phar/tests/phar_oo_test.inc @@ -7,11 +7,26 @@ $pname = 'phar://' . $fname; $file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>'; $files = array(); -$files['a.php'] = '<?php echo "This is a.php\n"; ?>'; -$files['b.php'] = '<?php echo "This is b.php\n"; ?>'; -$files['b/c.php'] = '<?php echo "This is b/c.php\n"; ?>'; -$files['b/d.php'] = '<?php echo "This is b/d.php\n"; ?>'; -$files['e.php'] = '<?php echo "This is e.php\n"; ?>'; + +if (!isset($pharconfig)) $pharconfig = 0; + +switch($pharconfig) +{ + default: + case 0: + $files['a.php'] = '<?php echo "This is a.php\n"; ?>'; + $files['b.php'] = '<?php echo "This is b.php\n"; ?>'; + $files['b/c.php'] = '<?php echo "This is b/c.php\n"; ?>'; + $files['b/d.php'] = '<?php echo "This is b/d.php\n"; ?>'; + $files['e.php'] = '<?php echo "This is e.php\n"; ?>'; + break; + case 1: + $files['a.csv'] =<<<EOF +1,2,3 +2,a,b +3,"c","'e'" +EOF; +} $manifest = ''; foreach($files as $name => $cont) { |