cvs: pear-core /tests/PEAR_Downloader setup.php.inc test_download_abstractpackage.phpt test_download_alreadyinstalled.phpt
/tests/PEAR_Downloader/packages test-1.0.tgz

From: Date: Fri, 22 Oct 2004 03:05:59 +0000
Subject: cvs: pear-core /tests/PEAR_Downloader setup.php.inc test_download_abstractpackage.phpt test_download_alreadyinstalled.phpt
/tests/PEAR_Downloader/packages test-1.0.tgz
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-1111@lists.php.net to get a copy of this message
cellog Thu Oct 21 23:05:59 2004 EDT Added files: /pear-core/tests/PEAR_Downloader test_download_abstractpackage.phpt test_download_alreadyinstalled.phpt /pear-core/tests/PEAR_Downloader/packages test-1.0.tgz Modified files: /pear-core/tests/PEAR_Downloader setup.php.inc Log: basic full-blown downloader->download tests for package.xml1.0 with no deps

http://cvs.php.net/diff.php/pear-core/tests/PEAR_Downloader/setup.php.inc?r1=1.3&r2=1.4&ty=u Index: pear-core/tests/PEAR_Downloader/setup.php.inc diff -u pear-core/tests/PEAR_Downloader/setup.php.inc:1.3 pear-core/tests/PEAR_Downloader/setup.php.inc:1.4 --- pear-core/tests/PEAR_Downloader/setup.php.inc:1.3 Thu Oct 21 01:09:37 2004 +++ pear-core/tests/PEAR_Downloader/setup.php.inc Thu Oct 21 23:05:59 2004 @@ -92,17 +92,33 @@ class fake_log { var $_log = array(); + var $_download = array(); function log($level, $message) { $this->_log[] = array($level, $message); } + function _downloadCallback($msg, $params) + { + if ($msg == 'setup') { + $params = 'self'; + } + $this->_download[] = array($msg, $params); + } + function getLog() { $log = $this->_log; $this->_log = array(); return $log; } + + function getDownload() + { + $log = $this->_download; + $this->_download = array(); + return $log; + } } $fakelog = new fake_log; $config = &PEAR_Config::singleton($temp_path . '/pear.ini'); http://cvs.php.net/co.php/pear-core/tests/PEAR_Downloader/test_download_abstractpackage.phpt?r=1.1&p=1 Index: pear-core/tests/PEAR_Downloader/test_download_abstractpackage.phpt +++ pear-core/tests/PEAR_Downloader/test_download_abstractpackage.phpt --TEST-- PEAR_Downloader->download() with downloadable abstract package --SKIPIF-- <?php if (!getenv('PHP_PEAR_RUNTESTS')) { echo 'skip'; } ?> --FILE-- <?php require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $pathtopackagexml = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'packages'. DIRECTORY_SEPARATOR . 'test-1.0.tgz'; $GLOBALS['pearweb']->addHtmlConfig('http://www.example.com/test-1.0.tgz', $pathtopackagexml); $GLOBALS['pearweb']->addXmlrpcConfig('pear.php.net', 'package.getDownloadURL', array(array('package' => 'test', 'channel' => 'pear.php.net'), 'stable'), array('version' => '1.0', 'info' => array( 'package' => 'test', 'channel' => 'pear.php.net', 'license' => 'PHP License', 'summary' => 'test', 'description' => 'test', 'releasedate' => '2003-12-06 00:26:42', 'state' => 'stable', ), 'url' => 'http://www.example.com/test-1.0')); $dp = &new test_PEAR_Downloader($fakelog, array(), $config); $phpunit->assertNoErrors('after create'); $result = $dp->download(array('test')); $phpunit->assertEquals(1, count($result), 'return'); $phpunit->assertIsa('test_PEAR_Downloader_Package', $result[0], 'right class'); $phpunit->assertIsa('PEAR_PackageFile_v1', $pf = $result[0]->getPackageFile(), 'right kind of pf'); $phpunit->assertEquals('test', $pf->getPackage(), 'right package'); $phpunit->assertEquals('pear.php.net', $pf->getChannel(), 'right channel'); $dlpackages = $dp->getDownloadedPackages(); $phpunit->assertEquals(1, count($dlpackages), 'downloaded packages count'); $phpunit->assertEquals(3, count($dlpackages[0]), 'internals package count'); $phpunit->assertEquals(array('file', 'info', 'pkg'), array_keys($dlpackages[0]), 'indexes'); $phpunit->assertEquals($dp->getDownloadDir() . DIRECTORY_SEPARATOR . 'test-1.0.tgz', $dlpackages[0]['file'], 'file'); $phpunit->assertIsa('PEAR_PackageFile_v1', $dlpackages[0]['info'], 'info'); $phpunit->assertEquals('test', $dlpackages[0]['pkg'], 'test'); $after = $dp->getDownloadedPackages(); $phpunit->assertEquals(0, count($after), 'after getdp count'); $phpunit->assertEquals(array ( 0 => array ( 0 => 3, 1 => '+ tmp dir created at ' . $dp->getDownloadDir(), ), 1 => array ( 0 => 1, 1 => 'downloading test-1.0.tgz ...', ), 2 => array ( 0 => 1, 1 => 'Starting to download test-1.0.tgz (785 bytes)', ), 3 => array ( 0 => 1, 1 => '.', ), 4 => array ( 0 => 1, 1 => '...done: 785 bytes', ), ), $fakelog->getLog(), 'log messages'); $phpunit->assertEquals(array ( 0 => array ( 0 => 'setup', 1 => 'self', ), 1 => array ( 0 => 'saveas', 1 => 'test-1.0.tgz', ), 2 => array ( 0 => 'start', 1 => array ( 0 => 'test-1.0.tgz', 1 => '785', ), ), 3 => array ( 0 => 'bytesread', 1 => 785, ), 4 => array ( 0 => 'done', 1 => 785, ), ), $fakelog->getDownload(), 'download callback messages'); echo 'tests done'; ?> --EXPECT-- tests done http://cvs.php.net/co.php/pear-core/tests/PEAR_Downloader/test_download_alreadyinstalled.phpt?r=1.1&p=1 Index: pear-core/tests/PEAR_Downloader/test_download_alreadyinstalled.phpt +++ pear-core/tests/PEAR_Downloader/test_download_alreadyinstalled.phpt --TEST-- PEAR_Downloader->download() of package that is already installed --SKIPIF-- <?php if (!getenv('PHP_PEAR_RUNTESTS')) { echo 'skip'; } ?> --FILE-- <?php require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $pathtopackagexml = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'packages'. DIRECTORY_SEPARATOR . 'test-1.0.tgz'; $GLOBALS['pearweb']->addHtmlConfig('http://www.example.com/test-1.0.tgz', $pathtopackagexml); $GLOBALS['pearweb']->addXmlrpcConfig('pear.php.net', 'package.getDownloadURL', array(array('package' => 'test', 'channel' => 'pear.php.net'), 'stable'), array('version' => '1.0', 'info' => array( 'package' => 'test', 'channel' => 'pear.php.net', 'license' => 'PHP License', 'summary' => 'test', 'description' => 'test', 'releasedate' => '2003-12-06 00:26:42', 'state' => 'stable', ), 'url' => 'http://www.example.com/test-1.0')); $dp = &new test_PEAR_Downloader($fakelog, array(), $config); $pkg = &new PEAR_PackageFile($config); $pf = $pkg->fromTgzFile($pathtopackagexml, PEAR_VALIDATE_NORMAL); $registry = &$config->getRegistry(); $registry->addPackage2($pf); $phpunit->assertNoErrors('after create'); $result = $dp->download(array('test')); $phpunit->assertEquals(0, count($result), 'return'); $dlpackages = $dp->getDownloadedPackages(); $phpunit->assertEquals(0, count($dlpackages), 'downloaded packages count'); $phpunit->showAll(); $phpunit->assertEquals(array ( 0 => array ( 0 => 1, 1 => 'Skipping package "channel://pear.php.net/test", already installed as version 1.0', ), ), $fakelog->getLog(), 'log messages'); $phpunit->assertEquals(array (), $fakelog->getDownload(), 'download callback messages'); /************************************* nodeps *********************************/ $dp = &new test_PEAR_Downloader($fakelog, array('nodeps' => true), $config); $pkg = &new PEAR_PackageFile($config); $pf = $pkg->fromTgzFile($pathtopackagexml, PEAR_VALIDATE_NORMAL); $registry = &$config->getRegistry(); $registry->addPackage2($pf); $phpunit->assertNoErrors('after create'); $result = $dp->download(array('test')); $phpunit->assertEquals(0, count($result), 'return'); $dlpackages = $dp->getDownloadedPackages(); $phpunit->assertEquals(0, count($dlpackages), 'downloaded packages count'); $phpunit->showAll(); $phpunit->assertEquals(array ( 0 => array ( 0 => 1, 1 => 'Skipping package "channel://pear.php.net/test", already installed as version 1.0', ), ), $fakelog->getLog(), 'log messages'); $phpunit->assertEquals(array (), $fakelog->getDownload(), 'download callback messages'); /************************************* force *********************************/ $dp = &new test_PEAR_Downloader($fakelog, array('force' => true), $config); $result = $dp->download(array('test')); $phpunit->assertEquals(1, count($result), 'return'); $phpunit->assertIsa('test_PEAR_Downloader_Package', $result[0], 'right class'); $phpunit->assertIsa('PEAR_PackageFile_v1', $pf = $result[0]->getPackageFile(), 'right kind of pf'); $phpunit->assertEquals('test', $pf->getPackage(), 'right package'); $phpunit->assertEquals('pear.php.net', $pf->getChannel(), 'right channel'); $dlpackages = $dp->getDownloadedPackages(); $phpunit->assertEquals(1, count($dlpackages), 'downloaded packages count'); $phpunit->assertEquals(3, count($dlpackages[0]), 'internals package count'); $phpunit->assertEquals(array('file', 'info', 'pkg'), array_keys($dlpackages[0]), 'indexes'); $phpunit->assertEquals($dp->getDownloadDir() . DIRECTORY_SEPARATOR . 'test-1.0.tgz', $dlpackages[0]['file'], 'file'); $phpunit->assertIsa('PEAR_PackageFile_v1', $dlpackages[0]['info'], 'info'); $phpunit->assertEquals('test', $dlpackages[0]['pkg'], 'test'); $after = $dp->getDownloadedPackages(); $phpunit->assertEquals(0, count($after), 'after getdp count'); $phpunit->assertEquals(array ( 0 => array ( 0 => 3, 1 => '+ tmp dir created at ' . $dp->getDownloadDir(), ), 1 => array ( 0 => 1, 1 => 'downloading test-1.0.tgz ...', ), 2 => array ( 0 => 1, 1 => 'Starting to download test-1.0.tgz (785 bytes)', ), 3 => array ( 0 => 1, 1 => '.', ), 4 => array ( 0 => 1, 1 => '...done: 785 bytes', ), ), $fakelog->getLog(), 'log messages'); $phpunit->assertEquals(array ( 0 => array ( 0 => 'setup', 1 => 'self', ), 1 => array ( 0 => 'saveas', 1 => 'test-1.0.tgz', ), 2 => array ( 0 => 'start', 1 => array ( 0 => 'test-1.0.tgz', 1 => '785', ), ), 3 => array ( 0 => 'bytesread', 1 => 785, ), 4 => array ( 0 => 'done', 1 => 785, ), ), $fakelog->getDownload(), 'download callback messages'); echo 'tests done'; ?> --EXPECT-- tests done
« previous php.pear.core (#1111) next »