cvs: pear-core /tests/PEAR_Validate setup.php.inc test_validPackageName.phpt

From: Date: Wed, 03 Nov 2004 22:48:20 +0000
Subject: cvs: pear-core /tests/PEAR_Validate setup.php.inc test_validPackageName.phpt
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-1220@lists.php.net to get a copy of this message
cellog Wed Nov 3 17:48:20 2004 EDT Added files: /pear-core/tests/PEAR_Validate setup.php.inc test_validPackageName.phpt Log: add PEAR_Validate->validPackageName() test http://cvs.php.net/co.php/pear-core/tests/PEAR_Validate/setup.php.inc?r=1.1&p=1 Index: pear-core/tests/PEAR_Validate/setup.php.inc +++ pear-core/tests/PEAR_Validate/setup.php.inc <?php $server = 'pear.Chiara'; //$server = 'test.pear.php.net'; $temp_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'testinstallertemp'; function cleanall($dir = null) { if ($dir !== null) { $statedir = $dir; } else { $statedir = $GLOBALS['temp_path']; } if (file_exists($statedir)) { $dp = opendir($statedir); while ($ent = readdir($dp)) { if (in_array($ent, array('.', '..'))) { continue; } if (is_dir($statedir . DIRECTORY_SEPARATOR . $ent)) { cleanall($statedir . DIRECTORY_SEPARATOR . $ent); continue; } unlink($statedir . DIRECTORY_SEPARATOR . $ent); } closedir($dp); rmdir($statedir); } } register_shutdown_function('cleanall'); cleanall($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 dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'phpt_test.php.inc'; require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'download_test_classes.php.inc'; $phpunit = &new PEAR_PHPTest(true); 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; require_once 'PEAR/Config.php'; $config = &PEAR_Config::singleton();//($temp_path . '/pear.ini'); test_PEAR_Dependency2::singleton($config); /** * @param array * @return test_PEAR_Downloader_Package */ function &newFakeDownloaderPackage($options) { global $config, $fakelog; $downloader = &new test_PEAR_Downloader($fakelog, $options, $config); $p = &new test_PEAR_Downloader_Package($downloader); return $p; } require_once 'PEAR/PackageFile/Parser/v1.php'; require_once 'PEAR/PackageFile/Parser/v2.php'; require_once 'PEAR/PackageFile/v1.php'; require_once 'PEAR/PackageFile/v2.php'; require_once 'PEAR/Validate.php'; $v1parser = &new PEAR_PackageFile_Parser_v1; $v2parser = &new PEAR_PackageFile_Parser_v2; $val = new PEAR_Validate; ?> http://cvs.php.net/co.php/pear-core/tests/PEAR_Validate/test_validPackageName.phpt?r=1.1&p=1 Index: pear-core/tests/PEAR_Validate/test_validPackageName.phpt +++ pear-core/tests/PEAR_Validate/test_validPackageName.phpt --TEST-- PEAR_Validate->validPackageName() --SKIPIF-- <?php if (!getenv('PHP_PEAR_RUNTESTS')) { echo 'skip'; } ?> --FILE-- <?php require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc'; $res = $val->validPackageName('foo'); $phpunit->assertTrue($res, 'foo'); $res = $val->validPackageName('fooOO'); $phpunit->assertTrue($res, 'fooOO'); $res = $val->validPackageName('f9ooOO'); $phpunit->assertTrue($res, 'f9ooOO'); $res = $val->validPackageName('f9oo_OO'); $phpunit->assertTrue($res, 'f9oo_OO'); $res = $val->validPackageName('f9oo_OO2'); $phpunit->assertTrue($res, 'f9oo_OO2'); $res = $val->validPackageName('F9oo_OO2'); $phpunit->assertTrue($res, 'F9oo_OO2'); $res = $val->validPackageName('foo.com_Validate', 'foo.com_Validate'); $phpunit->assertTrue($res, 'foo.com_Validate valid'); $res = $val->validPackageName('_F9oo_OO2'); $phpunit->assertFalse($res, '_F9oo_OO2'); $res = $val->validPackageName('2_F9oo_OO2'); $phpunit->assertFalse($res, '2_F9oo_OO2'); $res = $val->validPackageName('foo.com_Validate'); $phpunit->assertFalse($res, 'foo.com_Validate'); $res = $val->validPackageName('foo.com_Validate', 'grnok'); $phpunit->assertFalse($res, 'foo.com_Validate grnok'); $res = $val->validPackageName('.foo.com_Validate', '.foo.com_Validate'); $phpunit->assertFalse($res, '.foo.com_Validate invalid'); echo 'tests done'; ?> --EXPECT-- tests done

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