]> granicus.if.org Git - php/commitdiff
new code coverage test, improve clarity of error message when chmod is used on a...
authorGreg Beaver <cellog@php.net>
Fri, 25 Apr 2008 15:53:02 +0000 (15:53 +0000)
committerGreg Beaver <cellog@php.net>
Fri, 25 Apr 2008 15:53:02 +0000 (15:53 +0000)
ext/phar/phar_object.c
ext/phar/tests/pharfileinfo_chmod.phpt [new file with mode: 0644]

index 0d01c57c3ebdf4426867408ffc08f57d87c519b1..c48bd9697cc3274f546244aa671e2b0fc64f7783 100755 (executable)
@@ -3513,7 +3513,7 @@ PHP_METHOD(PharFileInfo, chmod)
 
        if (entry_obj->ent.entry->is_temp_dir) {
                zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
-                       "Phar entry is a directory, cannot chmod"); \
+                       "Phar entry \"%s\" is a temporary directory (not an actual entry in the archive), cannot chmod", entry_obj->ent.entry->filename); \
                return;
        }
        if (PHAR_G(readonly) && !entry_obj->ent.entry->phar->is_data) {
diff --git a/ext/phar/tests/pharfileinfo_chmod.phpt b/ext/phar/tests/pharfileinfo_chmod.phpt
new file mode 100644 (file)
index 0000000..b0b31b8
--- /dev/null
@@ -0,0 +1,35 @@
+--TEST--
+Phar: PharFileInfo::chmod extra code coverage
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
+<?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
+$pname = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+
+$phar['a/b'] = 'hi there';
+
+$b = $phar['a/b'];
+try {
+$phar['a']->chmod(066);
+} catch (Exception $e) {
+echo $e->getMessage(), "\n";
+}
+$b->chmod(array());
+lstat($pname . '/a/b'); // sets BG(CurrentLStatFile)
+$b->chmod(0666);
+?>
+===DONE===
+--CLEAN--
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
+--EXPECTF--
+Phar entry "a" is a temporary directory (not an actual entry in the archive), cannot chmod
+
+Warning: PharFileInfo::chmod() expects parameter 1 to be long, array given in %spharfileinfo_chmod.php on line %d
+===DONE===
\ No newline at end of file