From 21460875fc983e22fd33cb108e9de5d897362715 Mon Sep 17 00:00:00 2001 From: Steph Fox Date: Sun, 4 May 2008 20:58:43 +0000 Subject: [PATCH] - Some tests for buildFromDirectory() --- ext/phar/tests/phar_buildfromdirectory1.phpt | 28 ++++++++++++ ext/phar/tests/phar_buildfromdirectory2.phpt | 27 +++++++++++ ext/phar/tests/phar_buildfromdirectory3.phpt | 27 +++++++++++ ext/phar/tests/phar_buildfromdirectory4.phpt | 48 ++++++++++++++++++++ ext/phar/tests/phar_buildfromdirectory5.phpt | 48 ++++++++++++++++++++ ext/phar/tests/phar_buildfromdirectory6.phpt | 40 ++++++++++++++++ 6 files changed, 218 insertions(+) create mode 100644 ext/phar/tests/phar_buildfromdirectory1.phpt create mode 100644 ext/phar/tests/phar_buildfromdirectory2.phpt create mode 100644 ext/phar/tests/phar_buildfromdirectory3.phpt create mode 100644 ext/phar/tests/phar_buildfromdirectory4.phpt create mode 100644 ext/phar/tests/phar_buildfromdirectory5.phpt create mode 100644 ext/phar/tests/phar_buildfromdirectory6.phpt diff --git a/ext/phar/tests/phar_buildfromdirectory1.phpt b/ext/phar/tests/phar_buildfromdirectory1.phpt new file mode 100644 index 0000000000..505b15036f --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Phar::buildFromDirectory() - readonly +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +buildFromDirectory(1); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; +} +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +string(24) "UnexpectedValueException" +Cannot write to archive - write operations restricted by INI setting +===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory2.phpt b/ext/phar/tests/phar_buildfromdirectory2.phpt new file mode 100644 index 0000000000..fcad4725a7 --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory2.phpt @@ -0,0 +1,27 @@ +--TEST-- +Phar::buildFromDirectory() - non-directory passed as first parameter +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +buildFromDirectory(1); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; +} +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +string(24) "UnexpectedValueException" +RecursiveDirectoryIterator::__construct(1): failed to open dir: No such file or directory +===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory3.phpt b/ext/phar/tests/phar_buildfromdirectory3.phpt new file mode 100644 index 0000000000..435bbdfba6 --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory3.phpt @@ -0,0 +1,27 @@ +--TEST-- +Phar::buildFromDirectory() - object passed as second parameter +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +buildFromDirectory('files', new stdClass); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; +} +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +Warning: Phar::buildFromDirectory() expects parameter 2 to be string, object given in %sphar_buildfromdirectory3.php on line %d +===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory4.phpt b/ext/phar/tests/phar_buildfromdirectory4.phpt new file mode 100644 index 0000000000..886cad82d6 --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory4.phpt @@ -0,0 +1,48 @@ +--TEST-- +Phar::buildFromDirectory(), directory exists +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +buildFromDirectory(dirname(__FILE__) . '/testdir')); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; +} + +var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar')); + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +array(4) { + ["file1.txt"]=> + string(%d) "%stestdir%cfile1.txt" + ["file2.txt"]=> + string(%d) "%stestdir%cfile2.txt" + ["file3.txt"]=> + string(%d) "%stestdir%cfile3.txt" + ["file4.txt"]=> + string(%d) "%stestdir%cfile4.txt" +} +bool(true) +===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory5.phpt b/ext/phar/tests/phar_buildfromdirectory5.phpt new file mode 100644 index 0000000000..fbf3e9b533 --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory5.phpt @@ -0,0 +1,48 @@ +--TEST-- +Phar::buildFromDirectory() with matching regex +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.txt/')); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; +} + +var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar')); + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +array(4) { + ["file1.txt"]=> + string(%d) "%stestdir%cfile1.txt" + ["file2.txt"]=> + string(%d) "%stestdir%cfile2.txt" + ["file3.txt"]=> + string(%d) "%stestdir%cfile3.txt" + ["file4.txt"]=> + string(%d) "%stestdir%cfile4.txt" +} +bool(true) +===DONE=== diff --git a/ext/phar/tests/phar_buildfromdirectory6.phpt b/ext/phar/tests/phar_buildfromdirectory6.phpt new file mode 100644 index 0000000000..2edd0962f1 --- /dev/null +++ b/ext/phar/tests/phar_buildfromdirectory6.phpt @@ -0,0 +1,40 @@ +--TEST-- +Phar::buildFromDirectory() with non-matching regex +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +buildFromDirectory(dirname(__FILE__) . '/testdir', '/\.php/')); +} catch (Exception $e) { + var_dump(get_class($e)); + echo $e->getMessage() . "\n"; +} + +var_dump(file_exists(dirname(__FILE__) . '/buildfromdirectory.phar')); + +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +array(0) { +} +bool(false) +===DONE=== -- 2.50.1