cvs: php-src /pear/tests pear_installer1.phpt

From: Date: Sat, 29 May 2004 09:03:43 +0000
Subject: cvs: php-src /pear/tests pear_installer1.phpt
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-349@lists.php.net to get a copy of this message
cellog Sat May 29 05:03:43 2004 EDT Modified files: /php-src/pear/tests pear_installer1.phpt Log: update checkDeps/extractDownloadFilename tests for channels http://cvs.php.net/diff.php/php-src/pear/tests/pear_installer1.phpt?r1=1.6&r2=1.7&ty=u Index: php-src/pear/tests/pear_installer1.phpt diff -u php-src/pear/tests/pear_installer1.phpt:1.6 php-src/pear/tests/pear_installer1.phpt:1.7 --- php-src/pear/tests/pear_installer1.phpt:1.6 Wed May 19 04:45:23 2004 +++ php-src/pear/tests/pear_installer1.phpt Sat May 29 05:03:43 2004 @@ -1,5 +1,5 @@ --TEST-- -PEAR_Installer test #1 +PEAR_Installer test extractDownloadFileName, checkDeps --SKIPIF-- <?php if (!getenv('PHP_PEAR_RUNTESTS')) { @@ -10,6 +10,7 @@ <?php require_once "PEAR/Installer.php"; +require_once 'PEAR/ChannelFile.php'; $temp_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp'; if (!is_dir($temp_path)) { @@ -18,7 +19,17 @@ touch($temp_path . DIRECTORY_SEPARATOR . 'user.conf'); // no UI is needed for these tests $ui = false; +$config = new PEAR_Config; +$config->set('php_dir', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp'); +$reg = &new PEAR_Registry($config->get('php_dir')); +$chan = new PEAR_ChannelFile; +$chan->setName('oddball'); +$chan->setServer('example.com'); +$chan->setSummary('oddball'); +$chan->setPackageNameRegex('[a-z][a-z0-9]*(?:\.[a-z0-9]+)*'); +$reg->addChannel($chan); $installer = new PEAR_Installer($ui); +$installer->config = &$config; echo "test extractDownloadFileName:\n"; echo 'existing file: '; echo ($temp_path . DIRECTORY_SEPARATOR . 'user.conf' == @@ -42,6 +53,18 @@ echo $installer->extractDownloadFileName('Testpackage-1.2', $ui); echo "\n"; var_dump($ui); +echo "valid match, has unknown channel:\n"; +var_dump($installer->extractDownloadFileName('Unknown::Testpackage', $ui)); +var_dump($ui); +echo "invalid match, has known channel, invalid package name:\n"; +var_dump($installer->extractDownloadFileName('Oddball::Testpackage', $ui)); +var_dump($ui); +echo "valid match, has known channel, valid package name:\n"; +var_dump($installer->extractDownloadFileName('Oddball::testpackage.third3', $ui)); +var_dump($ui); +echo "valid match, has known channel, valid package name, version:\n"; +var_dump($installer->extractDownloadFileName('Oddball::testpackage.third3-54.7354', $ui)); +var_dump($ui); echo "\ntest checkDeps 1:\n"; $fakerel = array('release_deps' => @@ -62,6 +85,28 @@ $res = ''; var_dump($installer->checkDeps($fakerel, $res)); var_dump($res); + +echo "\ntest checkDeps 1.1:\n"; +$fakerel = array('release_deps' => +array( + array( + 'type' => 'pkg', + 'rel '=> 'has', + 'name' => 'foo', + 'optional' => 'yes', + 'channel' => 'grob', + ), + array( + 'type' => 'pkg', + 'rel '=> 'ge', + 'version' => '1.6', + 'name' => 'bar', + 'channel' => 'prego', + ), +)); +$res = ''; +var_dump($installer->checkDeps($fakerel, $res)); +var_dump($res); $fakerel = array('release_deps' => array( array( @@ -75,8 +120,37 @@ $res = ''; var_dump($installer->checkDeps($fakerel, $res)); var_dump($res); -unlink($temp_path . DIRECTORY_SEPARATOR . 'user.conf'); -rmdir($temp_path); +$fakerel = array('release_deps' => +array( + array( + 'type' => 'pkg', + 'rel '=> 'has', + 'name' => 'foo', + 'optional' => 'yes', + 'channel' => 'purple', + ), +)); +echo "\ntest checkDeps 2.1:\n"; +$res = ''; +var_dump($installer->checkDeps($fakerel, $res)); +var_dump($res); +cleanall($temp_path); +function cleanall($dir) +{ + $dp = opendir($dir); + while ($ent = readdir($dp)) { + if ($ent == '.' || $ent == '..') { + continue; + } + if (is_dir($dir . DIRECTORY_SEPARATOR . $ent)) { + cleanall($dir . DIRECTORY_SEPARATOR . $ent); + } else { + unlink($dir . DIRECTORY_SEPARATOR . $ent); + } + } + closedir($dp); + rmdir($dir); +} ?> --EXPECT-- test extractDownloadFileName: @@ -90,13 +164,50 @@ NULL valid match, has version: Testpackage string(3) "1.2" +valid match, has unknown channel: +array(2) { + ["channel"]=> + string(7) "Unknown" + ["package"]=> + string(11) "Testpackage" +} +NULL +invalid match, has known channel, invalid package name: +string(20) "Oddball::Testpackage" +NULL +valid match, has known channel, valid package name: +array(2) { + ["channel"]=> + string(7) "Oddball" + ["package"]=> + string(18) "testpackage.third3" +} +NULL +valid match, has known channel, valid package name, version: +array(2) { + ["channel"]=> + string(7) "Oddball" + ["package"]=> + string(18) "testpackage.third3" +} +string(7) "54.7354" test checkDeps 1: bool(true) -string(23) " -requires package `bar'" +string(29) " +requires package `pear::bar'" + +test checkDeps 1.1: +bool(true) +string(30) " +requires package `prego::bar'" test checkDeps 2: bool(false) -string(77) "Optional dependencies: -package `foo' is recommended to utilize some features." +string(83) "Optional dependencies: +package `pear::foo' is recommended to utilize some features." + +test checkDeps 2.1: +bool(false) +string(85) "Optional dependencies: +package `purple::foo' is recommended to utilize some features." \ No newline at end of file

« previous php.pear.core (#349) next »