cvs: pear-core /PEAR Config.php Registry.php /tests/PEAR_Command_Config setup.php.inc /tests/PEAR_Command_Config/config-set test_setchannelval.phpt
test_setchannelval_defaultch.phpt

From: Date: Fri, 26 Nov 2004 21:10:32 +0000
Subject: cvs: pear-core /PEAR Config.php Registry.php /tests/PEAR_Command_Config setup.php.inc /tests/PEAR_Command_Config/config-set test_setchannelval.phpt
test_setchannelval_defaultch.phpt
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-26546@lists.php.net to get a copy of this message
cellog Fri Nov 26 16:10:32 2004 EDT Added files: /pear-core/tests/PEAR_Command_Config/config-set test_setchannelval.phpt test_setchannelval_defaultch.phpt Modified files: /pear-core/PEAR Config.php Registry.php /pear-core/tests/PEAR_Command_Config setup.php.inc Log: make setting the registry update the channels list. Add __uri to default list of channels 2 new tests

http://cvs.php.net/diff.php/pear-core/PEAR/Config.php?r1=1.81&r2=1.82&ty=u Index: pear-core/PEAR/Config.php diff -u pear-core/PEAR/Config.php:1.81 pear-core/PEAR/Config.php:1.82 --- pear-core/PEAR/Config.php:1.81 Fri Nov 26 15:33:39 2004 +++ pear-core/PEAR/Config.php Fri Nov 26 16:10:31 2004 @@ -17,7 +17,7 @@ // | Greg Beaver <cellog@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Config.php,v 1.81 2004/11/26 20:33:39 cellog Exp $ +// $Id: Config.php,v 1.82 2004/11/26 21:10:31 cellog Exp $ require_once 'PEAR.php'; require_once 'PEAR/Registry.php'; @@ -249,7 +249,7 @@ * @var array * @access private */ - var $_channels = array('pear.php.net'); + var $_channels = array('pear.php.net', '__uri'); /** * This variable is used to control the directory values returned @@ -1197,14 +1197,19 @@ * * This should be set via a call to {@link PEAR_Registry::listChannels()} * @param array + * @param bool * @return bool success of operation */ - function setChannels($channels) + function setChannels($channels, $merge = false) { if (!is_array($channels)) { return false; } - $this->_channels = $channels; + if ($merge) { + $this->_channels = array_merge($this->_channels, $channels); + } else { + $this->_channels = $channels; + } foreach ($channels as $channel) { $channel = strtolower($channel); if ($channel == 'pear.php.net') { http://cvs.php.net/diff.php/pear-core/PEAR/Registry.php?r1=1.95&r2=1.96&ty=u Index: pear-core/PEAR/Registry.php diff -u pear-core/PEAR/Registry.php:1.95 pear-core/PEAR/Registry.php:1.96 --- pear-core/PEAR/Registry.php:1.95 Sun Nov 21 22:38:10 2004 +++ pear-core/PEAR/Registry.php Fri Nov 26 16:10:31 2004 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Registry.php,v 1.95 2004/11/22 03:38:10 cellog Exp $ +// $Id: Registry.php,v 1.96 2004/11/26 21:10:31 cellog Exp $ /* TODO: @@ -138,6 +138,7 @@ function setConfig(&$config) { $this->_config = &$config; + $config->setChannels($this->listChannels(), true); } function _initializeChannelDirs() http://cvs.php.net/diff.php/pear-core/tests/PEAR_Command_Config/setup.php.inc?r1=1.1&r2=1.2&ty=u Index: pear-core/tests/PEAR_Command_Config/setup.php.inc diff -u pear-core/tests/PEAR_Command_Config/setup.php.inc:1.1 pear-core/tests/PEAR_Command_Config/setup.php.inc:1.2 --- pear-core/tests/PEAR_Command_Config/setup.php.inc:1.1 Fri Nov 26 15:14:11 2004 +++ pear-core/tests/PEAR_Command_Config/setup.php.inc Fri Nov 26 16:10:32 2004 @@ -69,7 +69,7 @@ require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'phpt_test.php.inc'; $phpunit = &new PEAR_PHPTest(true); $fakelog = new fake_log; -$config = &PEAR_Config::singleton($temp_path . '/pear.ini'); +$config = &PEAR_Config::singleton($temp_path . '/pear.ini', $temp_path . '/pear.conf'); test_PEAR_Dependency2::singleton($config); require_once 'PEAR/Downloader/Package.php'; /** http://cvs.php.net/co.php/pear-core/tests/PEAR_Command_Config/config-set/test_setchannelval.phpt?r=1.1&p=1 Index: pear-core/tests/PEAR_Command_Config/config-set/test_setchannelval.phpt +++ pear-core/tests/PEAR_Command_Config/config-set/test_setchannelval.phpt --TEST-- config-set command, channel-specific value --SKIPIF-- <?php if (!getenv('PHP_PEAR_RUNTESTS')) { echo 'skip'; } ?> --FILE-- <?php error_reporting(E_ALL); require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $phpunit->assertEquals($temp_path . DIRECTORY_SEPARATOR . 'php', $config->get('php_dir'), $config->get('php_dir', 'user', '__uri'), 'setup'); $command->run('config-set', array('channel' => '__uri'), array('php_dir', 'poo')); $phpunit->assertNoErrors('after opt user'); $phpunit->assertEquals(array ( 0 => array ( 'info' => 'config-set succeeded', 'cmd' => 'config-set', ), ), $fakelog->getLog(), 'ui log, opt user'); $phpunit->assertEquals('poo', $config->get('php_dir', 'user', '__uri'), 'php_dir opt system'); $phpunit->assertEquals($temp_path . DIRECTORY_SEPARATOR . 'php', $config->get('php_dir', 'system', '__uri'), 'setup opt system'); $command->run('config-set', array('channel' => '__uri'), array('php_dir', 'poo', 'system')); $phpunit->assertNoErrors('after'); $phpunit->assertEquals(array ( 0 => array ( 'info' => 'config-set succeeded', 'cmd' => 'config-set', ), ), $fakelog->getLog(), 'ui log opt system'); $phpunit->assertEquals('poo', $config->get('php_dir', 'system', '__uri'), 'php_dir system opt'); $configinfo = array('master_server' => $server, 'preferred_state' => 'stable', 'cache_dir' => $temp_path . DIRECTORY_SEPARATOR . 'cache', 'php_dir' => $temp_path . DIRECTORY_SEPARATOR . 'php', 'ext_dir' => $temp_path . DIRECTORY_SEPARATOR . 'ext', 'data_dir' => $temp_path . DIRECTORY_SEPARATOR . 'data', 'doc_dir' => $temp_path . DIRECTORY_SEPARATOR . 'doc', 'test_dir' => $temp_path . DIRECTORY_SEPARATOR . 'test', 'bin_dir' => $temp_path . DIRECTORY_SEPARATOR . 'bin', '__channels' => array('__uri' => array('php_dir' => 'poo'))); $info = explode("\n", implode('', file($temp_path . DIRECTORY_SEPARATOR . 'pear.ini'))); $info = unserialize($info[1]); $phpunit->assertEquals($configinfo, $info, 'saved 1'); $info = explode("\n", implode('', file($temp_path . DIRECTORY_SEPARATOR . 'pear.conf'))); $info = unserialize($info[1]); $phpunit->assertEquals($configinfo, $info, 'saved 2'); echo 'tests done'; ?> --EXPECT-- tests done http://cvs.php.net/co.php/pear-core/tests/PEAR_Command_Config/config-set/test_setchannelval_defaultch.phpt?r=1.1&p=1 Index: pear-core/tests/PEAR_Command_Config/config-set/test_setchannelval_defaultch.phpt +++ pear-core/tests/PEAR_Command_Config/config-set/test_setchannelval_defaultch.phpt --TEST-- config-set command, channel-specific value --SKIPIF-- <?php if (!getenv('PHP_PEAR_RUNTESTS')) { echo 'skip'; } ?> --FILE-- <?php error_reporting(E_ALL); require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $config->set('default_channel', '__uri'); $phpunit->assertEquals($temp_path . DIRECTORY_SEPARATOR . 'php', $config->get('php_dir', 'user', '__uri'), 'setup default_ch'); $command->run('config-set', array(), array('php_dir', 'poo', 'user')); $phpunit->assertNoErrors('after user default_ch'); $phpunit->assertEquals(array ( 0 => array ( 'info' => 'config-set succeeded', 'cmd' => 'config-set', ), ), $fakelog->getLog(), 'ui log user default_ch'); $phpunit->assertEquals('poo', $config->get('php_dir', 'user', '__uri'), 'php_dir user default_ch'); $phpunit->assertEquals($temp_path . DIRECTORY_SEPARATOR . 'php', $config->get('php_dir', 'system', '__uri'), 'setup system default_ch'); $command->run('config-set', array(), array('php_dir', 'poo', 'system')); $phpunit->assertNoErrors('after'); $phpunit->assertEquals(array ( 0 => array ( 'info' => 'config-set succeeded', 'cmd' => 'config-set', ), ), $fakelog->getLog(), 'ui log system default_ch'); $phpunit->assertEquals('poo', $config->get('php_dir', 'system', '__uri'), 'php_dir system default_ch'); $configinfo = array('master_server' => $server, 'preferred_state' => 'stable', 'cache_dir' => $temp_path . DIRECTORY_SEPARATOR . 'cache', 'php_dir' => $temp_path . DIRECTORY_SEPARATOR . 'php', 'ext_dir' => $temp_path . DIRECTORY_SEPARATOR . 'ext', 'data_dir' => $temp_path . DIRECTORY_SEPARATOR . 'data', 'doc_dir' => $temp_path . DIRECTORY_SEPARATOR . 'doc', 'test_dir' => $temp_path . DIRECTORY_SEPARATOR . 'test', 'bin_dir' => $temp_path . DIRECTORY_SEPARATOR . 'bin', '__channels' => array('__uri' => array('php_dir' => 'poo')), 'default_channel' => '__uri'); $info = explode("\n", implode('', file($temp_path . DIRECTORY_SEPARATOR . 'pear.ini'))); $info = unserialize($info[1]); $phpunit->assertEquals($configinfo, $info, 'saved 1'); unset($configinfo['default_channel']); $info = explode("\n", implode('', file($temp_path . DIRECTORY_SEPARATOR . 'pear.conf'))); $info = unserialize($info[1]); $phpunit->assertEquals($configinfo, $info, 'saved 2'); echo 'tests done'; ?> --EXPECT-- tests done
« previous php.pear.cvs (#26546) next »