cvs: pear /PEAR_Info/tests AllTests.php PEAR_Info_TestCase_CustomConfig.php PEAR_Info_TestCase_DefaultConfig.php

From: Date: Thu, 05 Jul 2007 17:13:18 +0000
Subject: cvs: pear /PEAR_Info/tests AllTests.php PEAR_Info_TestCase_CustomConfig.php PEAR_Info_TestCase_DefaultConfig.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-47875@lists.php.net to get a copy of this message
farell Thu Jul 5 17:13:18 2007 UTC Added files: /pear/PEAR_Info/tests AllTests.php PEAR_Info_TestCase_CustomConfig.php PEAR_Info_TestCase_DefaultConfig.php Log: first unit test cases for PEAR_Info package (run with PHPUnit 3.x)

http://cvs.php.net/viewvc.cgi/pear/PEAR_Info/tests/AllTests.php?view=markup&rev=1.1 Index: pear/PEAR_Info/tests/AllTests.php +++ pear/PEAR_Info/tests/AllTests.php <?php /** * PEAR_Info no-regression test suite * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category PEAR * @package PEAR_Info * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 Laurent Laville * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: AllTests.php,v 1.1 2007/07/05 17:13:18 farell Exp $ * @link http://pear.php.net/package/PEAR_Info * @since File available since Release 1.7.0 */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'AllTests::main'); } require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; require_once 'PEAR_Info_TestCase_DefaultConfig.php'; require_once 'PEAR_Info_TestCase_CustomConfig.php'; /** * PEAR_Info no-regression test suite * * Run all tests from the package root directory: * #phpunit AllTests tests/AllTests.php * or * #php tests/AllTests.php * or for code coverage testing * #phpunit --report tests/coverage AllTests tests/AllTests.php * * After the code coverage test browse the index.html file in tests/coverage. * The code coverage is close to 100%. * * @category PEAR * @package PEAR_Info * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 Laurent Laville * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: AllTests.php,v 1.1 2007/07/05 17:13:18 farell Exp $ * @link http://pear.php.net/package/PEAR_Info * @since Class available since Release 1.7.0 */ class AllTests { /** * Runs the test suite * * @return void * @access public * @static * @since 1.7.0 */ public static function main() { PHPUnit_TextUI_TestRunner::run(self::suite()); } /** * Runs the test suite * * @return object the PHPUnit_Framework_TestSuite object * @access public * @static * @since 1.7.0 */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('PEAR_Info Test Suite'); $suite->addTestSuite('PEAR_Info_TestCase_DefaultConfig'); $suite->addTestSuite('PEAR_Info_TestCase_CustomConfig'); return $suite; } } if (PHPUnit_MAIN_METHOD == 'AllTests::main') { AllTests::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/PEAR_Info/tests/PEAR_Info_TestCase_CustomConfig.php?view=markup&rev=1.1 Index: pear/PEAR_Info/tests/PEAR_Info_TestCase_CustomConfig.php +++ pear/PEAR_Info/tests/PEAR_Info_TestCase_CustomConfig.php <?php /** * PEAR_Info unit test case for custom configuration files usage. * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category PEAR * @package PEAR_Info * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 Laurent Laville * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: PEAR_Info_TestCase_CustomConfig.php,v 1.1 2007/07/05 17:13:18 farell Exp $ * @link http://pear.php.net/package/PEAR_Info * @since File available since Release 1.7.0 */ if (!defined("PHPUnit_MAIN_METHOD")) { define("PHPUnit_MAIN_METHOD", "PEAR_Info_TestCase_CustomConfig::main"); } require_once 'PHPUnit/Framework.php'; /** * Unit test case for PEAR_Info custom configuration files usage. * * @category PEAR * @package PEAR_Info * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 Laurent Laville * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: PEAR_Info_TestCase_CustomConfig.php,v 1.1 2007/07/05 17:13:18 farell Exp $ * @link http://pear.php.net/package/PEAR_Info * @since Class available since Release 1.7.0 */ class PEAR_Info_TestCase_CustomConfig extends PHPUnit_Framework_TestCase { /** * Runs the test methods of this class. * * @access public * @static */ public static function main() { require_once "PHPUnit/TextUI/TestRunner.php"; $suite = new PHPUnit_Framework_TestSuite("PEAR_Info test custom configuration"); $result = PHPUnit_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { // we get PEAR_Info class only here due to setting of PEAR_CONFIG_SYSCONFDIR // in PEAR Info TestCase DefaultConfig require_once 'PEAR/Info.php'; } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * Test class constructor with only $pear_dir parameter. * * Will try to detect if default user config files (pear.ini | .pearrc), * and/or default system config files (pearsys.ini | pear.conf) are available * into $pear_dir directory. * * @access public * @since 1.7.0 */ public function testConfigFilesExistWithDefaultNameInPearDir() { $pearDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pear_dir'; $pearInfo = new PEAR_Info($pearDir); $this->assertTrue(is_a($pearInfo, 'PEAR_Info')); } /** * Test class constructor with first 3 parameters ($pear_dir, $user_file, and $system_file). * * Will try to detect if user config files (named pear.custom.ini), * and/or system config files (named pearsys.custom.ini) are available * into $pear_dir directory. * * @access public * @since 1.7.0 */ public function testConfigFilesExistWithCustomNameInPearDir() { $pearDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pear_dir' . DIRECTORY_SEPARATOR; $userFile = $pearDir . 'pear.custom.ini'; $systemFile = $pearDir . 'pearsys.custom.ini'; $pearInfo = new PEAR_Info($pearDir, $userFile, $systemFile); $this->assertTrue(is_a($pearInfo, 'PEAR_Info')); } /** * Test class constructor with parameters ($user_file, and $system_file). * * Will try to detect if user config files (named pear.custom.ini), * and/or system config files (named pearsys.custom.ini) are available. * * @access public * @since 1.7.0 */ public function testConfigFilesExistInUsrConfDir() { $userDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'user_dir' . DIRECTORY_SEPARATOR; $userFile = $userDir . 'pear.custom.ini'; $systemFile = $userDir . 'pearsys.custom.ini'; $pearInfo = new PEAR_Info('', $userFile, $systemFile); $this->assertTrue(is_a($pearInfo, 'PEAR_Info')); } } // Call PEAR_Info_TestCase_CustomConfig::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "PEAR_Info_TestCase_CustomConfig::main") { PEAR_Info_TestCase_CustomConfig::main(); } ?> http://cvs.php.net/viewvc.cgi/pear/PEAR_Info/tests/PEAR_Info_TestCase_DefaultConfig.php?view=markup&rev=1.1 Index: pear/PEAR_Info/tests/PEAR_Info_TestCase_DefaultConfig.php +++ pear/PEAR_Info/tests/PEAR_Info_TestCase_DefaultConfig.php <?php /** * PEAR_Info unit test case for default configuration files usage. * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category PEAR * @package PEAR_Info * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 Laurent Laville * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: PEAR_Info_TestCase_DefaultConfig.php,v 1.1 2007/07/05 17:13:18 farell Exp $ * @link http://pear.php.net/package/PEAR_Info * @since File available since Release 1.7.0 */ if (!defined("PHPUnit_MAIN_METHOD")) { define("PHPUnit_MAIN_METHOD", "PEAR_Info_TestCase_DefaultConfig::main"); } require_once 'PHPUnit/Framework.php'; /** * Unit test case for PEAR_Info default configuration files usage. * * @category PEAR * @package PEAR_Info * @author Laurent Laville <pear@laurent-laville.org> * @copyright 2007 Laurent Laville * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: PEAR_Info_TestCase_DefaultConfig.php,v 1.1 2007/07/05 17:13:18 farell Exp $ * @link http://pear.php.net/package/PEAR_Info * @since Class available since Release 1.7.0 */ class PEAR_Info_TestCase_DefaultConfig extends PHPUnit_Framework_TestCase { /** * Saves content of PHP_PEAR_SYSCONF_DIR environment variable * * @var string * @access private * @since 1.7.0 */ private $sysconfdir; /** * Runs the test methods of this class. * * @access public * @static * @since 1.7.0 */ public static function main() { require_once "PHPUnit/TextUI/TestRunner.php"; $suite = new PHPUnit_Framework_TestSuite("PEAR_Info test default configuration"); $result = PHPUnit_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected * @since 1.7.0 */ protected function setUp() { $this->sysconfdir = getenv('PHP_PEAR_SYSCONF_DIR'); putenv("PHP_PEAR_SYSCONF_DIR=" . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'sysconf_dir'); // debug-code: error_log('set PHP_PEAR_SYSCONF_DIR to ' . getenv('PHP_PEAR_SYSCONF_DIR'), 0); // we get PEAR_Info class only here due to setting of PEAR_CONFIG_SYSCONFDIR require_once 'PEAR/Info.php'; } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected * @since 1.7.0 */ protected function tearDown() { putenv("PHP_PEAR_SYSCONF_DIR=" . $this->sysconfdir); // debug-code: error_log('restore PHP_PEAR_SYSCONF_DIR to ' . getenv('PHP_PEAR_SYSCONF_DIR'), 0); } /** * Test default class constructor without parameter. * * Must use the pear config files into the default system directory (PEAR_CONFIG_SYSCONFDIR). * * @access public * @since 1.7.0 */ public function testConfigFilesExistInSysConfDir() { $pearInfo = new PEAR_Info(); $this->assertTrue(is_a($pearInfo, 'PEAR_Info')); } } // Call PEAR_Info_TestCase_DefaultConfig::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "PEAR_Info_TestCase_DefaultConfig::main") { PEAR_Info_TestCase_DefaultConfig::main(); } ?>
« previous php.pear.cvs (#47875) next »