$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 .
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()));
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
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)
==>test php-const replacement: equals 'good stuff'? => good stuff