diff options
author | Greg Beaver <cellog@php.net> | 2003-09-17 00:00:21 +0000 |
---|---|---|
committer | Greg Beaver <cellog@php.net> | 2003-09-17 00:00:21 +0000 |
commit | 7a0fcc45a80cb7cd45ff0b5a60c425803b137057 (patch) | |
tree | 96beec0573f9c710eaf75280daa6a70590c9b229 | |
parent | 1b76db05e74894696d900ed6c2fdeca36848d939 (diff) | |
download | php-git-7a0fcc45a80cb7cd45ff0b5a60c425803b137057.tar.gz |
some beginning tests for commitFileTransaction()
-rw-r--r-- | pear/tests/pear_installer3.phpt | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/pear/tests/pear_installer3.phpt b/pear/tests/pear_installer3.phpt index c3c80cf5b8..0deba55f5d 100644 --- a/pear/tests/pear_installer3.phpt +++ b/pear/tests/pear_installer3.phpt @@ -60,7 +60,7 @@ require_once "PEAR/Installer.php"; // no UI is needed for these tests $ui = false; $installer = new PEAR_Installer($ui); -$installer->debug = 3; // hack debugging in +$installer->debug = 2; // hack debugging in $curdir = getcwd(); chdir(dirname(__FILE__)); @@ -72,6 +72,45 @@ echo (get_class($err) == 'pear_error' ? " yes\n" : " no\n"); if (get_class($err) == 'pear_error') { echo $err->getMessage() . "\n"; } +echo 'count($installer->file_operations) = '; +var_dump(count($installer->file_operations)); +echo "Do valid addFileOperation() delete\n"; +touch($temp_path . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'installertestfooblah.phpt'); +$installer->addFileOperation('delete', array($temp_path . DIRECTORY_SEPARATOR . + 'tmp' . DIRECTORY_SEPARATOR . 'installertestfooblah.phpt')); +echo 'count($installer->file_operations) = '; +var_dump(count($installer->file_operations)); + +echo "test valid commitFileTransaction():\n"; +if ($installer->commitFileTransaction()) { + echo "worked\n"; +} else { + echo "didn't work!\n"; +} + +echo "Do valid addFileOperation() delete with non-existing file\n"; +$installer->addFileOperation('delete', array('gloober62456.phpt')); +echo 'count($installer->file_operations) = '; +var_dump(count($installer->file_operations)); + +echo "test invalid commitFileTransaction():\n"; +if ($installer->commitFileTransaction()) { + echo "worked\n"; +} else { + echo "didn't work!\n"; +} + +echo "Do valid addFileOperation() rename with non-existing file\n"; +$installer->addFileOperation('rename', array('gloober62456.phpt', 'faber.com')); +echo 'count($installer->file_operations) = '; +var_dump(count($installer->file_operations)); + +echo "test invalid commitFileTransaction():\n"; +if ($installer->commitFileTransaction()) { + echo "worked\n"; +} else { + echo "didn't work!\n"; +} //cleanup chdir($curdir); @@ -94,3 +133,23 @@ test addFileOperation(): invalid input to addFileOperation(): Returned PEAR_Error? yes Internal Error: $data in addFileOperation must be an array, was integer +count($installer->file_operations) = int(0) +Do valid addFileOperation() delete +count($installer->file_operations) = int(1) +test valid commitFileTransaction(): +about to commit 1 file operations +successfully committed 1 file operations +worked +Do valid addFileOperation() delete with non-existing file +count($installer->file_operations) = int(1) +test invalid commitFileTransaction(): +about to commit 1 file operations +warning: file gloober62456.phpt doesn't exist, can't be deleted +successfully committed 1 file operations +worked +Do valid addFileOperation() rename with non-existing file +count($installer->file_operations) = int(1) +test invalid commitFileTransaction(): +about to commit 1 file operations +cannot rename file gloober62456.phpt, doesn't exist +didn't work! |