cvs: pear-core /tests/PEAR_Command_Config setup.php.inc /tests/PEAR_Command_Config/config-set test_fail.phpt
| From: | Greg Beaver | Date: | Fri, 26 Nov 2004 20:14:11 +0000 |
| Subject: | cvs: pear-core /tests/PEAR_Command_Config setup.php.inc /tests/PEAR_Command_Config/config-set test_fail.phpt | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-26537@lists.php.net to get a copy of this message | ||
cellog Fri Nov 26 15:14:11 2004 EDT
Added files:
/pear-core/tests/PEAR_Command_Config/config-set test_fail.phpt
/pear-core/tests/PEAR_Command_Config setup.php.inc
Log:
new test
http://cvs.php.net/co.php/pear-core/tests/PEAR_Command_Config/config-set/test_fail.phpt?r=1.1&p=1
Index: pear-core/tests/PEAR_Command_Config/config-set/test_fail.phpt
+++ pear-core/tests/PEAR_Command_Config/config-set/test_fail.phpt
--TEST--
config-set command failure
--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';
$e = $command->run('config-set', array(), array());
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' =>
'config-set expects 2 or 3 parameters'),
), 'no params');
$e = $command->run('config-set', array(), array('default_channel'));
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' =>
'config-set expects 2 or 3 parameters'),
), '1 params');
$e = $command->run('config-set', array(), array('default_channel',
'pear', 'gronk'));
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' =>
'config-set: only the layers: "user" or "system" are supported'),
), 'unknown layer');
$e = $command->run('config-set', array(), array('default_channel',
'gronk'));
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => 'Channel
"gronk" does not exist'),
), 'unknown channel');
$e = $command->run('config-set', array('channel' => 'gronk'),
array('php_dir', 'gronk'));
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => 'Channel
"gronk" does not exist'),
), 'unknown channel as option');
$e = $command->run('config-set', array(), array('__channels',
'gronk'));
$phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' =>
'config-set (__channels, gronk) failed, channel pear.php.net'),
), 'unknown channel as option');
echo 'tests done';
?>
--EXPECT--
tests done
http://cvs.php.net/co.php/pear-core/tests/PEAR_Command_Config/setup.php.inc?r=1.1&p=1
Index: pear-core/tests/PEAR_Command_Config/setup.php.inc
+++ pear-core/tests/PEAR_Command_Config/setup.php.inc
<?php
$server = 'pear.Chiara';
//$server = 'test.pear.php.net';
$temp_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp';
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR .
'download_test_classes.php.inc';
register_shutdown_function('cleanall');
cleanall($temp_path);
$statedir = $temp_path;
if (!is_dir($temp_path)) {
mkdir($temp_path);
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'php')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'php');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'data')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'data');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'doc')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'doc');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'test')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'test');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'ext')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'ext');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'script')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'script');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'tmp')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'tmp');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'bin')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'bin');
}
if (!is_dir($temp_path . DIRECTORY_SEPARATOR . 'cache')) {
mkdir($temp_path . DIRECTORY_SEPARATOR . 'cache');
}
// make the fake configuration - we'll use one of these and it should work
$config = serialize(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',));
touch($temp_path . DIRECTORY_SEPARATOR . 'pear.conf');
$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'pear.conf', 'w');
fwrite($fp, $config);
fclose($fp);
touch($temp_path . DIRECTORY_SEPARATOR . 'pear.ini');
$fp = fopen($temp_path . DIRECTORY_SEPARATOR . 'pear.ini', 'w');
fwrite($fp, $config);
fclose($fp);
putenv('PHP_PEAR_SYSCONF_DIR='.$temp_path);
$home = getenv('HOME');
if (!empty($home)) {
// for PEAR_Config initialization
putenv('HOME="'.$temp_path);
}
require_once "PEAR/Downloader.php";
require_once dirname(dirname(__FILE__)) . '/download_test_classes.php.inc';
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');
test_PEAR_Dependency2::singleton($config);
require_once 'PEAR/Downloader/Package.php';
/**
* @param array
* @return PEAR_Downloader_Package
*/
function &newDownloaderPackage($options)
{
global $config, $fakelog;
$downloader = &new test_PEAR_Downloader($fakelog, $options, $config);
$p = &new PEAR_Downloader_Package($downloader);
return $p;
}
require_once 'PEAR/Command/Config.php';
$command = &new PEAR_Command_Config($fakelog, $config);
?>