cvs: php-src /pear/tests pear_installer2.phpt
| From: | Greg Beaver | Date: | Sun, 14 Sep 2003 20:19:59 +0000 |
| Subject: | cvs: php-src /pear/tests pear_installer2.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-12735@lists.php.net to get a copy of this message | ||
cellog Sun Sep 14 16:19:59 2003 EDT
Modified files:
/php-src/pear/tests pear_installer2.phpt
Log:
add testing for md5sum
Index: php-src/pear/tests/pear_installer2.phpt
diff -u php-src/pear/tests/pear_installer2.phpt:1.4 php-src/pear/tests/pear_installer2.phpt:1.5
--- php-src/pear/tests/pear_installer2.phpt:1.4 Sun Sep 14 16:02:07 2003
+++ php-src/pear/tests/pear_installer2.phpt Sun Sep 14 16:19:59 2003
@@ -119,7 +119,7 @@
$temp_path . DIRECTORY_SEPARATOR . 'tmp', array());
echo 'returned PEAR_Error: ' . (get_class($err) == 'pear_error' ?
"yes\n" : "no\n");
if (is_object($err)) {
- echo 'message: ' . $err->getMessage() . "\n";
+ echo 'message: ' . $err->getMessage() . "\n\n";
}
echo 'file bin/.tmpinstaller2.phpt.testfile.php exists? => ';
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR .
@@ -136,11 +136,43 @@
echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR .
'.tmp....php') ? "yes\n" : "no\n");
-define('PEARINSTALLERTEST2_FAKE_FOO_CONST', 'good');
-echo "\ntest replacements:\n";
$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR .
'installer2.phpt.testfile.php', 'w');
fwrite($fp, '@TEST@ stuff');
fclose($fp);
+
+echo "\ntest valid md5sum:\n";
+var_dump($installer->_installFile('installer2.phpt.testfile.php',
array('role' => 'script', 'md5sum' => md5('@TEST@
stuff')),
+ $temp_path . DIRECTORY_SEPARATOR . 'tmp', array()));
+echo 'file bin/.tmpinstaller2.phpt.testfile.php exists? => ';
+echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR .
+ '.tmpinstaller2.phpt.testfile.php') ? "yes\n" : "no\n");
+
+$installer->rollbackFileTransaction();
+
+echo "test invalid md5sum:\n";
+$err = $installer->_installFile('installer2.phpt.testfile.php', array('role'
=> 'script', 'md5sum' => md5('oops stuff')),
+ $temp_path . DIRECTORY_SEPARATOR . 'tmp', array());
+echo 'returned PEAR_Error: ' . (get_class($err) == 'pear_error' ?
"yes\n" : "no\n");
+if (is_object($err)) {
+ echo 'message: ' . $err->getMessage() . "\n";
+}
+echo 'file bin/.tmpinstaller2.phpt.testfile.php exists? => ';
+echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR .
+ '.tmpinstaller2.phpt.testfile.php') ? "yes\n" : "no\n");
+
+echo "test invalid md5sum with --force:\n";
+$err = $installer->_installFile('installer2.phpt.testfile.php', array('role'
=> 'script', 'md5sum' => md5('oops stuff')),
+ $temp_path . DIRECTORY_SEPARATOR . 'tmp', array('force' => true));
+echo 'returned PEAR_Error: ' . (get_class($err) == 'pear_error' ?
"yes\n" : "no\n");
+if (is_object($err)) {
+ echo 'message: ' . $err->getMessage() . "\n";
+}
+echo 'file bin/.tmpinstaller2.phpt.testfile.php exists? => ';
+echo (file_exists($temp_path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR .
+ '.tmpinstaller2.phpt.testfile.php') ? "yes\n" : "no\n");
+
+define('PEARINSTALLERTEST2_FAKE_FOO_CONST', 'good');
+echo "\ntest replacements:\n";
var_dump($installer->_installFile('installer2.phpt.testfile.php',
array('role' => 'script',
'replacements' => array(array('type' => 'php-const',
'from' => '@TEST@', 'to' =>
'PEARINSTALLERTEST2_FAKE_FOO_CONST'))),
$temp_path . DIRECTORY_SEPARATOR . 'tmp', array()));
@@ -227,7 +259,6 @@
install as role="script":
int(1)
file bin/.tmpinstaller2.phpt.testfile.php exists? => yes
-file bin/.tmpinstaller2.phpt.testfile.php exists? => yes
install as invalid role="klingon":
returned PEAR_Error: yes
message: Invalid role `klingon' for file installer2.phpt.testfile.php
@@ -237,6 +268,18 @@
returned PEAR_Error: yes
message: file does not exist
file bin/.tmp....php exists? => no
+
+test valid md5sum:
+int(1)
+file bin/.tmpinstaller2.phpt.testfile.php exists? => yes
+test invalid md5sum:
+returned PEAR_Error: yes
+message: bad md5sum for file c:\web pages\chiara\testinstallertemp\bin\installer2.phpt.testfile.php
+file bin/.tmpinstaller2.phpt.testfile.php exists? => no
+test invalid md5sum with --force:
+warning : bad md5sum for file c:\web
pages\chiara\testinstallertemp\bin\installer2.phpt.testfile.php
+returned PEAR_Error: no
+file bin/.tmpinstaller2.phpt.testfile.php exists? => yes
test replacements:
int(1)