com php-src: Added tests for ZipArchive::addGlob() and ZipArchive::addPattern(): ext/zip/tests/oo_addglob.phpt e xt/zip/tests/oo_addpattern.phpt

From: Date: Fri, 23 May 2014 05:51:13 +0000
Subject: com php-src: Added tests for ZipArchive::addGlob() and ZipArchive::addPattern(): ext/zip/tests/oo_addglob.phpt e xt/zip/tests/oo_addpattern.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-78512@lists.php.net to get a copy of this message
Commit: e2bbe9531053bd6b69e9fc6a2ad1cb602f977c6a Author: Sammy Kaye Powers <sammyk@sammykmedia.com> Fri, 23 May 2014 05:34:44 +0000 Committer: vagrant <sammyk@sammykmedia.com> Fri, 23 May 2014 05:51:13 +0000 Parents: 5d1bfd6fbfbb1474b23b0b58ef81f8396b361fca Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e2bbe9531053bd6b69e9fc6a2ad1cb602f977c6a Log: Added tests for ZipArchive::addGlob() and ZipArchive::addPattern() Changed paths: A ext/zip/tests/oo_addglob.phpt A ext/zip/tests/oo_addpattern.phpt Diff: diff --git a/ext/zip/tests/oo_addglob.phpt b/ext/zip/tests/oo_addglob.phpt new file mode 100644 index 0000000..970bfc7 --- /dev/null +++ b/ext/zip/tests/oo_addglob.phpt @@ -0,0 +1,50 @@ +--TEST-- +ZipArchive::addGlob() method +--CREDITS-- +Sammy Kaye Powers <sammyk@sammykmedia.com> +w/Kenzo over the shoulder +#phptek Chicago 2014 +--SKIPIF-- +<?php +/* $Id$ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__tmp_oo_addglob.zip'; + +copy($dirname . 'test.zip', $file); +touch($dirname . 'foo.txt'); +touch($dirname . 'bar.baz'); + +$zip = new ZipArchive(); +if (!$zip->open($file)) { + exit('failed'); +} +$options = array('add_path' => 'baz/', 'remove_all_path' => TRUE); +if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options)) { + echo "failed1\n"; +} +if ($zip->status == ZIPARCHIVE::ER_OK) { + dump_entries_name($zip); + $zip->close(); +} else { + echo "failed2\n"; +} +?> +--CLEAN-- +<?php +$dirname = dirname(__FILE__) . '/'; +unlink($dirname . '__tmp_oo_addglob.zip'); +unlink($dirname . 'foo.txt'); +unlink($dirname . 'bar.baz'); +?> +--EXPECTF-- +0 bar +1 foobar/ +2 foobar/baz +3 entry1.txt +4 baz/foo.txt +5 baz/bar.baz diff --git a/ext/zip/tests/oo_addpattern.phpt b/ext/zip/tests/oo_addpattern.phpt new file mode 100644 index 0000000..4e1cab4 --- /dev/null +++ b/ext/zip/tests/oo_addpattern.phpt @@ -0,0 +1,51 @@ +--TEST-- +ZipArchive::addPattern() method +--CREDITS-- +Sammy Kaye Powers <sammyk@sammykmedia.com> +w/Kenzo over the shoulder +#phptek Chicago 2014 +--SKIPIF-- +<?php +/* $Id$ */ +if(!extension_loaded('zip')) die('skip'); +?> +--FILE-- +<?php +$dirname = dirname(__FILE__) . '/'; +include $dirname . 'utils.inc'; +$file = $dirname . '__tmp_oo_addpattern.zip'; + +copy($dirname . 'test.zip', $file); +touch($dirname . 'foo.txt'); +touch($dirname . 'bar.txt'); + +$zip = new ZipArchive(); +if (!$zip->open($file)) { + exit('failed'); +} +$dir = realpath($dirname); +$options = array('add_path' => 'baz/', 'remove_path' => $dir); +if (!$zip->addPattern('/\.txt$/', $dir, $options)) { + echo "failed\n"; +} +if ($zip->status == ZIPARCHIVE::ER_OK) { + dump_entries_name($zip); + $zip->close(); +} else { + echo "failed\n"; +} +?> +--CLEAN-- +<?php +$dirname = dirname(__FILE__) . '/'; +unlink($dirname . '__tmp_oo_addpattern.zip'); +unlink($dirname . 'foo.txt'); +unlink($dirname . 'bar.txt'); +?> +--EXPECTF-- +0 bar +1 foobar/ +2 foobar/baz +3 entry1.txt +4 baz/bar.txt +5 baz/foo.txt

« previous php.cvs (#78512) next »