com phpruntests: Reformatted to conform to PEAR coding standard.: src/configuration/exceptions/rtEnvironmentException.php
src/configuration/exceptions/rtMissingArgumentException.php src/configuration/exceptions/rtUnknownIniSettingException.php
src/configuration/exceptions/rtUnknownOptionException.php src/configuration/preconditions/rtIfParallelHasPcntl.php
src/configuration/preconditions/rtIsExecutableSet.php src/configuration/preconditions/rtIsP
| From: | David Soria Parra | Date: | Mon, 20 Apr 2009 20:24:30 +0000 |
| Subject: | com phpruntests: Reformatted to conform to PEAR coding standard.: src/configuration/exceptions/rtEnvironmentException.php src/configuration/exceptions/rtMissingArgumentException.php src/configuration/exceptions/rtUnknownIniSettingException.php src/configuration/exceptions/rtUnknownOptionException.php src/configuration/preconditions/rtIfParallelHasPcntl.php src/configuration/preconditions/rtIsExecutableSet.php src/configuration/preconditions/rtIsP |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66542@lists.php.net to get a copy of this message | ||
Commit: e311693412c35efb4fd377f8f6364775f2bbe77c
Author: Stefan Priebsch <spriebsch@php.net> Mon, 20 Apr 2009 20:24:30 +0000
Parents: 3f014b8dcaf7b5ac627d5880ed0139afc3deb6e1
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=e311693412c35efb4fd377f8f6364775f2bbe77c
Log:
Reformatted to conform to PEAR coding standard.
Changed paths:
M src/configuration/exceptions/rtEnvironmentException.php
M src/configuration/exceptions/rtMissingArgumentException.php
M src/configuration/exceptions/rtUnknownIniSettingException.php
M src/configuration/exceptions/rtUnknownOptionException.php
M src/configuration/preconditions/rtIfParallelHasPcntl.php
M src/configuration/preconditions/rtIsExecutableSet.php
M src/configuration/preconditions/rtIsPcreLoaded.php
M src/configuration/preconditions/rtIsProcOpenAvailable.php
M src/configuration/preconditions/rtIsSafeModeDisabled.php
M src/configuration/preconditions/rtIsTestFileSpecified.php
M src/configuration/rtAddToCommandLine.php
M src/configuration/rtCommandLineOptions.php
M src/configuration/rtEnvironmentVariables.php
M src/configuration/rtIniAsCommandLineArgs.php
M src/configuration/rtPreCondition.php
M src/configuration/rtPreConditionList.php
M src/configuration/rtRuntestsConfiguration.php
M src/configuration/rtSetting.php
M src/configuration/settings/rtCurrentDirectorySetting.php
M src/configuration/settings/rtLogFormatSetting.php
M src/configuration/settings/rtPhpCgiExecutableSetting.php
M src/configuration/settings/rtPhpCommandLineArgSetting.php
M src/configuration/settings/rtPhpExecutableSetting.php
M src/configuration/settings/rtTestDirectorySetting.php
M src/configuration/settings/rtTestFileSetting.php
M src/configuration/settings/rtWorkingDirectorySetting.php
M src/rtDirectoryList.php
diff --git a/src/configuration/exceptions/rtEnvironmentException.php b/src/configuration/exceptions/rtEnvironmentException.php index e39bc01..c345081 100644 --- a/src/configuration/exceptions/rtEnvironmentException.php +++ b/src/configuration/exceptions/rtEnvironmentException.php @@ -1,7 +1,6 @@ <?php - class rtEnvironmentException extends RunTimeException - { - } - +class rtEnvironmentException extends RunTimeException +{ +} ?> diff --git a/src/configuration/exceptions/rtMissingArgumentException.php b/src/configuration/exceptions/rtMissingArgumentException.php index 048fb9a..5e90d36 100644 --- a/src/configuration/exceptions/rtMissingArgumentException.php +++ b/src/configuration/exceptions/rtMissingArgumentException.php @@ -1,7 +1,6 @@ <?php - class rtMissingArgumentException extends RuntimeException - { - } - +class rtMissingArgumentException extends RuntimeException +{ +} ?> diff --git a/src/configuration/exceptions/rtUnknownIniSettingException.php b/src/configuration/exceptions/rtUnknownIniSettingException.php index 2565e1b..f1ebe2c 100644 --- a/src/configuration/exceptions/rtUnknownIniSettingException.php +++ b/src/configuration/exceptions/rtUnknownIniSettingException.php @@ -1,7 +1,6 @@ <?php - class rtUnknownIniSettingException extends RuntimeException - { - } - +class rtUnknownIniSettingException extends RuntimeException +{ +} ?> diff --git a/src/configuration/exceptions/rtUnknownOptionException.php b/src/configuration/exceptions/rtUnknownOptionException.php index 9f9f5fb..4bb2c36 100644 --- a/src/configuration/exceptions/rtUnknownOptionException.php +++ b/src/configuration/exceptions/rtUnknownOptionException.php @@ -1,7 +1,6 @@ <?php - class rtUnknownOptionException extends RuntimeException - { - } - +class rtUnknownOptionException extends RuntimeException +{ +} ?> diff --git a/src/configuration/preconditions/rtIfParallelHasPcntl.php b/src/configuration/preconditions/rtIfParallelHasPcntl.php index f2801a1..e6f8f1f 100644 --- a/src/configuration/preconditions/rtIfParallelHasPcntl.php +++ b/src/configuration/preconditions/rtIfParallelHasPcntl.php @@ -4,31 +4,32 @@ * Class for checking whether the PCNTL extension is loaded * */ -class rtIfParallelHasPcntl extends rtPreCondition { - - - /** - * Return the message associated with missing PCRE - * - * @return text - */ - public function getMessage() { - return rtText::get('pcntlNotLoaded'); - } +class rtIfParallelHasPcntl extends rtPreCondition +{ + /** + * Return the message associated with missing PCRE + * + * @return text + */ + public function getMessage() + { + return rtText::get('pcntlNotLoaded'); + } + /** + * Check that the PCNTL is loaded if parallel run is required + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if ($commandLine->hasOption('z') || $environmentVariables->hasVariable('TESTS_PHP_PARALLEL')) { + if (!extension_loaded('pcntl')) { + return false; + } + } - /** - * Check that the PCNTL is loaded if parallel run is required - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if($commandLine->hasOption('z') || $environmentVariables->hasVariable('TESTS_PHP_PARALLEL')) { - if(!extension_loaded('pcntl')) { - return false; - } + return true; } - return true; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsExecutableSet.php b/src/configuration/preconditions/rtIsExecutableSet.php index 0cd2cc3..836ae94 100644 --- a/src/configuration/preconditions/rtIsExecutableSet.php +++ b/src/configuration/preconditions/rtIsExecutableSet.php @@ -4,35 +4,36 @@ * Class for checking whether a PHP Executable has been set * */ -class rtIsExecutableSet extends rtPreCondition { - - - /** - * Return the message associated with a missing PHP executable - * - * @return text - */ - public function getMessage() { - return rtText::get('missingPHPExecutable'); - } - - - /** - * Check that the PHP executable is a valid executable - * - * @param rtCommandLine $commandLine - * @param rtEnvironmentVariables $environment - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if($commandLine->hasOption('p')) { - return true; - } - if($environmentVariables->hasVariable('TEST_PHP_EXECUTABLE')) { - return true; +class rtIsExecutableSet extends rtPreCondition +{ + /** + * Return the message associated with a missing PHP executable + * + * @return text + */ + public function getMessage() + { + return rtText::get('missingPHPExecutable'); } - return false; - } - + + /** + * Check that the PHP executable is a valid executable + * + * @param rtCommandLine $commandLine + * @param rtEnvironmentVariables $environment + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if ($commandLine->hasOption('p')) { + return true; + } + + if ($environmentVariables->hasVariable('TEST_PHP_EXECUTABLE')) { + return true; + } + + return false; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsPcreLoaded.php b/src/configuration/preconditions/rtIsPcreLoaded.php index e5ed5dc..78acc7f 100644 --- a/src/configuration/preconditions/rtIsPcreLoaded.php +++ b/src/configuration/preconditions/rtIsPcreLoaded.php @@ -3,29 +3,30 @@ * Class for checking whether the PCRE extension is loaded * */ -class rtIsPcreLoaded extends rtPreCondition { +class rtIsPcreLoaded extends rtPreCondition +{ + /** + * Return the message associated with missing PCRE + * + * @return text + */ + public function getMessage() + { + return rtText::get('pcreNotLoaded'); + } - - /** - * Return the message associated with missing PCRE - * - * @return text - */ - public function getMessage() { - return rtText::get('pcreNotLoaded'); - } - - - /** - * Check that the PCRE is loaded - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if(extension_loaded('pcre')) { - return true; + /** + * Check that the PCRE is loaded + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if (extension_loaded('pcre')) { + return true; + } + + return false; } - return false; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsProcOpenAvailable.php b/src/configuration/preconditions/rtIsProcOpenAvailable.php index e469b35..21bc802 100644 --- a/src/configuration/preconditions/rtIsProcOpenAvailable.php +++ b/src/configuration/preconditions/rtIsProcOpenAvailable.php @@ -4,29 +4,30 @@ * Class for checking whether proc_open() is available * */ -class rtIsProcOpenAvailable extends rtPreCondition { +class rtIsProcOpenAvailable extends rtPreCondition +{ + /** + * Return the message associated with missing proc_open(); + * + * @return text + */ + public function getMessage() + { + return rtText::get('procOpenNotAvailable'); + } + + /** + * Check that proc_open() is available + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if (function_exists('proc_open')) { + return true; + } - - /** - * Return the message associated with missing proc_open(); - * - * @return text - */ - public function getMessage() { - return rtText::get('procOpenNotAvailable'); - } - - - /** - * Check that proc_open() is available - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if(function_exists('proc_open')) { - return true; + return false; } - return false; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsSafeModeDisabled.php b/src/configuration/preconditions/rtIsSafeModeDisabled.php index 112d17d..d12d6d0 100644 --- a/src/configuration/preconditions/rtIsSafeModeDisabled.php +++ b/src/configuration/preconditions/rtIsSafeModeDisabled.php @@ -4,29 +4,30 @@ * Class for checking if safe_mode is enabled * */ -class rtIsSafeModeDisabled extends rtPreCondition { - - - /** - * Return the message associated with safe mode enabled - * - * @return text - */ - public function getMessage() { - return rtText::get('safeModeNotDisabled'); - } +class rtIsSafeModeDisabled extends rtPreCondition +{ + /** + * Return the message associated with safe mode enabled + * + * @return text + */ + public function getMessage() + { + return rtText::get('safeModeNotDisabled'); + } + /** + * Check to see if safe mode is enabled + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if (!ini_get('safe_mode')) { + return true; + } - /** - * Check to see if safe mode is enabled - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if(!ini_get('safe_mode')) { - return true; + return false; } - return false; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsTestFileSpecified.php b/src/configuration/preconditions/rtIsTestFileSpecified.php index 12b0c48..bdf79eb 100644 --- a/src/configuration/preconditions/rtIsTestFileSpecified.php +++ b/src/configuration/preconditions/rtIsTestFileSpecified.php @@ -4,41 +4,44 @@ * Class for checking that a test file, or directory has been specified * */ -class rtIsTestFileSpecified extends rtPreCondition { - - - /** - * Return the message associated with a missing PHP test file - * - * @return text - */ - public function getMessage() { - return rtText::get('missingTestFile'); - } - - - /** - * Check that a test file or directory has been given - * - * @param rtCommandLine $commandLine - * @param rtEnvironmentVariables $environmentVariables - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if($commandLine->hasOption('l')) { - return true; - } - if($commandLine->hasOption('r')) { - return true; - } - if($commandLine->getTestFilename() != null) { - return true; +class rtIsTestFileSpecified extends rtPreCondition +{ + /** + * Return the message associated with a missing PHP test file + * + * @return text + */ + public function getMessage() + { + return rtText::get('missingTestFile'); } - if($environmentVariables->hasVariable('TEST_PHP_USER')) { - return true; - } - return false; - } - + + /** + * Check that a test file or directory has been given + * + * @param rtCommandLine $commandLine + * @param rtEnvironmentVariables $environmentVariables + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if($commandLine->hasOption('l')) { + return true; + } + + if($commandLine->hasOption('r')) { + return true; + } + + if($commandLine->getTestFilename() != null) { + return true; + } + + if($environmentVariables->hasVariable('TEST_PHP_USER')) { + return true; + } + + return false; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtAddToCommandLine.php b/src/configuration/rtAddToCommandLine.php index 14ea700..89f9717 100644 --- a/src/configuration/rtAddToCommandLine.php +++ b/src/configuration/rtAddToCommandLine.php @@ -5,22 +5,20 @@ * that additional arguments are parsed * */ -class rtAddToCommandLine { - - - /** - * Parse additional values if supplied by env variable - * - * @param rtCommandLineOptions $commandLine - * @param rtEnvironmentVariables $environmentVariables - */ - public static function parseAdditionalOptions($commandLine, $environmentVariables) { - - if ($environmentVariables->hasVariable('TEST_PHP_ARGS')) { - $additionalOptions = array_merge(array('run-test.php'), explode(" ", $environmentVariables->getVariable('TEST_PHP_ARGS'))); - $commandLine->parse($additionalOptions); - } - } - +class rtAddToCommandLine +{ + /** + * Parse additional values if supplied by env variable + * + * @param rtCommandLineOptions $commandLine + * @param rtEnvironmentVariables $environmentVariables + */ + public static function parseAdditionalOptions($commandLine, $environmentVariables) + { + if ($environmentVariables->hasVariable('TEST_PHP_ARGS')) { + $additionalOptions = array_merge(array('run-test.php'), explode(" ", $environmentVariables->getVariable('TEST_PHP_ARGS'))); + $commandLine->parse($additionalOptions); + } + } } ?> diff --git a/src/configuration/rtCommandLineOptions.php b/src/configuration/rtCommandLineOptions.php index c036232..4a42880 100644 --- a/src/configuration/rtCommandLineOptions.php +++ b/src/configuration/rtCommandLineOptions.php @@ -10,200 +10,181 @@ */ class rtCommandLineOptions { -/** - * - */ - protected $shortOptions = array( - 'n', - 'm', - 'q', - 'x', - 'v', - 'h', - 'z', //parallel - run out of obvious letters - ); - - protected $shortOptionsWithArgs = array( - 'l', - 'r', - 'w', - 'a', - 'c', - 'd', - 'p', - 's', - ); - - protected $longOptions = array( - 'verbose', - 'help', - 'keep-all', - 'keep-php', - 'keep-skip', - 'keep-clean', - 'keep-out', - 'keep-exp', - 'show-all', - 'show-php', - 'show-skip', - 'show-clean', - 'show-exp', - 'show-diff', - 'show-out', - 'no-clean', - ); - - protected $longOptionsWithArgs = array( - 'html', - 'temp-source', - 'temp-target', - 'set-timeout', - ); + /** + * + */ + protected $shortOptions = array( + 'n', + 'm', + 'q', + 'x', + 'v', + 'h', + 'z', //parallel - run out of obvious letters + ); + + protected $shortOptionsWithArgs = array( + 'l', + 'r', + 'w', + 'a', + 'c', + 'd', + 'p', + 's', + ); + + protected $longOptions = array( + 'verbose', + 'help', + 'keep-all', + 'keep-php', + 'keep-skip', + 'keep-clean', + 'keep-out', + 'keep-exp', + 'show-all', + 'show-php', + 'show-skip', + 'show-clean', + 'show-exp', + 'show-diff', + 'show-out', + 'no-clean', + ); + + protected $longOptionsWithArgs = array( + 'html', + 'temp-source', + 'temp-target', + 'set-timeout', + ); - protected $options = array(); - - protected $testFilename = array(); - - /** - * Enter description here... - * - */ + protected $options = array(); - public function __construct() - { - } + protected $testFilename = array(); + public function __construct() + { + } - public function parse($argv) - { - $this->parseCommandLineOptions($this->stripSpaces($argv)); - } - - - protected function isShortOption($arg) - { - return (substr($arg, 0, 1) == '-') && (substr($arg, 1, 1) != '-'); - } + public function parse($argv) + { + $this->parseCommandLineOptions($this->stripSpaces($argv)); + } + protected function isShortOption($arg) + { + return (substr($arg, 0, 1) == '-') && (substr($arg, 1, 1) != '-'); + } - protected function isLongOption($arg) - { - return substr($arg, 0, 2) == '--'; - } - - - /** - * Parse command line, expects to find: - * -{shortOption} - * -{shortOptionWithArg} {arg} - * --{longOption} - * --{longOptionWithArg} {arg} - * file name|directory name - */ - public function parseCommandLineOptions($argv) - { - for ($i=0; $i<count($argv); $i++) + protected function isLongOption($arg) { + return substr($arg, 0, 2) == '--'; + } - if (!$this->isShortOption($argv[$i]) && !$this->isLongOption($argv[$i])) - { - $this->testFilename[] = $argv[$i]; - continue; + /** + * Parse command line, expects to find: + * -{shortOption} + * -{shortOptionWithArg} {arg} + * --{longOption} + * --{longOptionWithArg} {arg} + * file name|directory name + */ + public function parseCommandLineOptions($argv) + { + for ($i=0; $i<count($argv); $i++) { + + if (!$this->isShortOption($argv[$i]) && !$this->isLongOption($argv[$i])) { + $this->testFilename[] = $argv[$i]; + continue; + } + + if ($this->isShortOption($argv[$i])) { + $option = substr($argv[$i], 1); + } else { + $option = substr($argv[$i], 2); + } + + if (!in_array($option, array_merge($this->shortOptions, $this->shortOptionsWithArgs, $this->longOptions, $this->longOptionsWithArgs))) { + throw new rtUnknownOptionException('Unknown option ' . $argv[$i]); + } + + if (in_array($option, array_merge($this->shortOptions, $this->longOptions))) { + $this->options[$option] = true; + continue; + } + + if (!$this->isValidOptionArg($argv, $i + 1)) { + throw new rtMissingArgumentException('Missing argument for command line option ' . $argv[$i]); + } + + $i++; + $this->options[$option] = $argv[$i]; } + } - if ($this->isShortOption($argv[$i])) - { - $option = substr($argv[$i], 1); - } else { - $option = substr($argv[$i], 2); - } - if (!in_array($option, array_merge($this->shortOptions, $this->shortOptionsWithArgs, $this->longOptions, $this->longOptionsWithArgs))) - { - throw new rtUnknownOptionException('Unknown option ' . $argv[$i]); + /** + * Checks to make sure that the arument following does not begin with "-" + * @param string - argument + * @return bool + */ + public function isValidOptionArg($array, $index) + { + if (!isset($array[$index])) { + return false; } + return substr($array[$index], 0, 1) != '-'; + } - if (in_array($option, array_merge($this->shortOptions, $this->longOptions))) - { - $this->options[$option] = true; - continue; - } - if (!$this->isValidOptionArg($argv, $i + 1)) - { - throw new rtMissingArgumentException('Missing argument for command line option ' . $argv[$i]); - } + /** + * Removes spaces in command line arguments AND strips $argv[0] + * @param array - command line arguments + * @return array - command line args with blank entries removed + */ + protected function stripSpaces($argv) + { + $result = array(); - $i++; - $this->options[$option] = $argv[$i]; + for ($i=1; $i<count($argv); $i++) { + if ($argv[$i] != "") { + $result[] = $argv[$i]; + } + } + return $result; } - } - /** - * Checks to make sure that the arument following does not begin with "-" - * @param string - argument - * @return bool - */ - public function isValidOptionArg($array, $index) - { - if (!isset($array[$index])) + /** + * + */ + public function getOption($option) { - return false; - } - return substr($array[$index], 0, 1) != '-'; - } + if (!isset($this->options[$option])) { + return false; + } + return $this->options[$option]; + } - /** - * Removes spaces in command line arguments AND strips $argv[0] - * @param array - command line arguments - * @return array - command line args with blank entries removed - */ - protected function stripSpaces($argv) - { - $result = array(); - for ($i=1; $i<count($argv); $i++) + /** + * Check whether an option exists + */ + public function hasOption($option) { - if ($argv[$i] != "") { - $result[] = $argv[$i]; - } + return isset($this->options[$option]); } - return $result; - } - /** - * - */ - public function getOption($option) - { - if (!isset($this->options[$option])) { - return false; + /** + * Return the array containing file names or directory names to be tested + */ + public function getTestFilename() + { + return $this->testFilename; } - return $this->options[$option]; - } - - - /** - * Check whether an option exists - */ - public function hasOption($option) - { - return isset($this->options[$option]); - } - - - /** - * Return the array containing file names or directory names to be tested - */ - public function getTestFilename() - { - return $this->testFilename; - } - - } - ?> diff --git a/src/configuration/rtEnvironmentVariables.php b/src/configuration/rtEnvironmentVariables.php index e33c6bc..227ab0a 100644 --- a/src/configuration/rtEnvironmentVariables.php +++ b/src/configuration/rtEnvironmentVariables.php @@ -5,68 +5,71 @@ * Needs some changes - don't document till complete * */ -class rtEnvironmentVariables { +class rtEnvironmentVariables +{ + protected $userSuppliedVariables = array ( + 'TEST_PHP_EXECUTABLE', + 'TEST_PHP_SRCDIR', + 'TEST_PHP_CGI_EXECUTABLE', + 'TEST_PHP_LOG_FORMAT', + 'TEST_PHP_DETAILED', + 'TEST_PHP_USER', + 'NO_INTERACTION', + 'PHP_AUTOCONF', + 'TEST_PHP_ARGS', + 'REPORT_EXIT_STATUS', + 'TEST_PHP_ERROR_STYLE', + 'NO_PHPTEST_SUMMARY', + ); - protected $userSuppliedVariables = array ( - 'TEST_PHP_EXECUTABLE', - 'TEST_PHP_SRCDIR', - 'TEST_PHP_CGI_EXECUTABLE', - 'TEST_PHP_LOG_FORMAT', - 'TEST_PHP_DETAILED', - 'TEST_PHP_USER', - 'NO_INTERACTION', - 'PHP_AUTOCONF', - 'TEST_PHP_ARGS', - 'REPORT_EXIT_STATUS', - 'TEST_PHP_ERROR_STYLE', - 'NO_PHPTEST_SUMMARY', - ); + private $environmentVariables; - private $environmentVariables; - - public function __construct() { - - } + public function __construct() + { + } - public static function getInstance ($os = 'Unix') - { - if ($os == 'Windows') { - return new rtWinEnvironmentVariables(); - } else { - return new rtUnixEnvironmentVariables(); + static public function getInstance ($os = 'Unix') + { + if ($os == 'Windows') { + return new rtWinEnvironmentVariables(); + } else { + return new rtUnixEnvironmentVariables(); + } } - } + public function getUserSuppliedVariables() + { + if (isset($_ENV)) { + $this->environmentVariables = $_ENV; + } else { + $this->environmentVariables = array(); + } - public function getUserSuppliedVariables() { - if (isset($_ENV)) { - $this->environmentVariables = $_ENV; - } else { - $this->environmentVariables = array(); + foreach($this->userSuppliedVariables as $variable) { + if(getenv($variable)) { + $this->environmentVariables[$variable] = getenv($variable); + } + } } - foreach($this->userSuppliedVariables as $variable) { - if(getenv($variable)) { - $this->environmentVariables[$variable] = getenv($variable); - } + public function setVariable($var,$value) + { + $this->environmentVariables[$var] = $value; } - } - public function setVariable($var,$value) { - $this->environmentVariables[$var] = $value; - } - - public function getVariable($var) { - return $this->environmentVariables[$var]; - } - - public function hasVariable($var) { - return (isset ($this->environmentVariables[$var])); - } - - public function getVariables() { - return $this->environmentVariables; - } + public function getVariable($var) + { + return $this->environmentVariables[$var]; + } + public function hasVariable($var) + { + return (isset ($this->environmentVariables[$var])); + } + + public function getVariables() + { + return $this->environmentVariables; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtIniAsCommandLineArgs.php b/src/configuration/rtIniAsCommandLineArgs.php index 2307488..1951b6a 100644 --- a/src/configuration/rtIniAsCommandLineArgs.php +++ b/src/configuration/rtIniAsCommandLineArgs.php @@ -1,103 +1,118 @@ <?php -class rtIniAsCommandLineArgs { - protected $iniOverwrites = array( - 'output_handler=', - 'open_basedir=', - 'safe_mode=0', - 'disable_functions=', - 'output_buffering=Off', - "error_reporting= 32767", - 'display_errors=1', - 'display_startup_errors=1', - 'log_errors=0', - 'html_errors=0', - 'track_errors=1', - 'report_memleaks=1', - 'report_zend_debug=0', - 'docref_root=', - 'docref_ext=.html', - 'error_prepend_string=', - 'error_append_string=', - 'auto_prepend_file=', - 'auto_append_file=', - 'magic_quotes_runtime=0', - 'ignore_repeated_errors=0', - 'unicode.runtime_encoding=ISO-8859-1', - 'unicode.script_encoding=UTF-8', - 'unicode.output_encoding=UTF-8', - 'unicode.from_error_mode=U_INVALID_SUBSTITUTE', - ); +class rtIniAsCommandLineArgs +{ + protected $iniOverwrites = array( + 'output_handler=', + 'open_basedir=', + 'safe_mode=0', + 'disable_functions=', + 'output_buffering=Off', + "error_reporting= 32767", + 'display_errors=1', + 'display_startup_errors=1', + 'log_errors=0', + 'html_errors=0', + 'track_errors=1', + 'report_memleaks=1', + 'report_zend_debug=0', + 'docref_root=', + 'docref_ext=.html', + 'error_prepend_string=', + 'error_append_string=', + 'auto_prepend_file=', + 'auto_append_file=', + 'magic_quotes_runtime=0', + 'ignore_repeated_errors=0', + 'unicode.runtime_encoding=ISO-8859-1', + 'unicode.script_encoding=UTF-8', + 'unicode.output_encoding=UTF-8', + 'unicode.from_error_mode=U_INVALID_SUBSTITUTE', + ); - protected $basePhpDArgs; + protected $basePhpDArgs; - /** - * - */ - public function setBase() { - $this->basePhpDArgs=$this->settingsToArguments($this->iniOverwrites); - } - /** - * Sets the -d flags used in the PHP command that executes the PHP - * code from a test case - * @param array - ini settings - * @param string - command line arguments to be extended - * @return string - command line arguments - * - */ - public function settingsToArguments($array, $args="") { - foreach($array as $setting) { - if($this->isValidSetting($setting)) { - $setting=$this->stripSpaces($setting); - $args.=" -d \"$setting\""; - } else { - throw new rtUnknownIniSettingException("Invalid INI setting $setting"); - } + /** + * + */ + public function setBase() + { + $this->basePhpDArgs = $this->settingsToArguments($this->iniOverwrites); } - return $args; - } - /** - * Checks that the ini setting is valid - * - * @param string - ini setting in the form a=b - * @return boolean - false if not in expected format - */ - public function isValidSetting($string) { - $parts = explode("=", $string, 2); - //explode failed - if ($parts[0] === $string) {return false;} + /** + * Sets the -d flags used in the PHP command that executes the PHP + * code from a test case + * @param array - ini settings + * @param string - command line arguments to be extended + * @return string - command line arguments + * + */ + public function settingsToArguments($array, $args="") + { + foreach($array as $setting) { + if($this->isValidSetting($setting)) { + $setting = $this->stripSpaces($setting); + $args .= " -d \"$setting\""; + } else { + throw new rtUnknownIniSettingException("Invalid INI setting $setting"); + } + } - //test for == - if(strncmp($parts[1], '=', 1) === 0) {return false;} + return $args; + } + + /** + * Checks that the ini setting is valid + * + * @param string - ini setting in the form a=b + * @return boolean - false if not in expected format + */ + public function isValidSetting($string) + { + $parts = explode("=", $string, 2); + + //explode failed + if ($parts[0] === $string) { + return false; + } - //test for a=b=c - if(strstr($parts[1], '=') == false) { - return true; - }else { - return false; + //test for == + if(strncmp($parts[1], '=', 1) === 0) { + return false; + } + + //test for a=b=c + if(strstr($parts[1], '=') == false) { + return true; + } else { + return false; + } } - } - /** - * Removes spaces from ini settings, "a = b" is retirned as "a=b" - * - * @param string - ini setting - * @return string - ini setting with any spaces removed - */ - public function stripSpaces($string){ - $noSpace=""; - $parts = explode("=",$string, 2); - $noSpace.=trim($parts[0])."=".trim($parts[1]); - return $noSpace; - } - /** - * Returns an array containing the PHP test execution flags - * - * @return unknown - */ - public function getBasePhpDArgs() { - return $this->basePhpDArgs; - } -} + /** + * Removes spaces from ini settings, "a = b" is retirned as "a=b" + * + * @param string - ini setting + * @return string - ini setting with any spaces removed + */ + public function stripSpaces($string) + { + $noSpace = ""; + $parts = explode("=", $string, 2); + $noSpace .= trim($parts[0]) . "=" . trim($parts[1]); + + return $noSpace; + } + + /** + * Returns an array containing the PHP test execution flags + * + * @return unknown + */ + public function getBasePhpDArgs() + { + return $this->basePhpDArgs; + } +} ?> diff --git a/src/configuration/rtPreCondition.php b/src/configuration/rtPreCondition.php index 6e582d8..4c47def 100644 --- a/src/configuration/rtPreCondition.php +++ b/src/configuration/rtPreCondition.php @@ -3,24 +3,24 @@ /** * A pre-condtion for running a test */ -class rtPreCondition { - - - /** - * The message to use if teh pre-condition is not met - * - */ - public function getMessage() { - } - - /** - * Code to check the pre-condition - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - return true; - } +class rtPreCondition +{ + /** + * The message to use if teh pre-condition is not met + * + */ + public function getMessage() + { + } + /** + * Code to check the pre-condition + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + return true; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtPreConditionList.php b/src/configuration/rtPreConditionList.php index c1e763a..2eab2e7 100644 --- a/src/configuration/rtPreConditionList.php +++ b/src/configuration/rtPreConditionList.php @@ -5,63 +5,62 @@ * platform run-tests is executed on * */ -abstract class rtPreConditionList { +abstract class rtPreConditionList +{ + protected $preConditions = array ( + 'rtIsExecutableSet', + 'rtIsPcreLoaded', + 'rtIsProcOpenAvailable', + 'rtIsSafeModeDisabled', + 'rtIsTestFileSpecified', + ); - protected $preConditions = array ( - 'rtIsExecutableSet', - 'rtIsPcreLoaded', - 'rtIsProcOpenAvailable', - 'rtIsSafeModeDisabled', - 'rtIsTestFileSpecified', - ); - - - /** - * Gets instance of a platform specific pre-condition list - * - * @param string $os - * @return rtPreConditionList Platform specific pre-condition list - */ - public static function getInstance ($os = 'Unix') - { - if ($os == 'Windows') { - return new rtWinPreconditionList('Windows'); - } else { - return new rtUnixPreConditionList(); + /** + * Gets instance of a platform specific pre-condition list + * + * @param string $os + * @return rtPreConditionList Platform specific pre-condition list + */ + static public function getInstance($os = 'Unix') + { + if ($os == 'Windows') { + return new rtWinPreconditionList('Windows'); + } else { + return new rtUnixPreConditionList(); + } } - } + /** + * Checks the validity of each pre-condition in the list + * + * @param rtCommandLineOptions $commandLine + * @param rtEnvironmentVariables $environmentVariables + * @return boolean + */ + public function check($commandLine, $environmentVariables) { + foreach($this->preConditions as $preCon) { + $p = new $preCon; + if(!$p->check($commandLine, $environmentVariables)) { + die($p->getMessage()); + } + } - /** - * Checks the validity of each pre-condition in the list - * - * @param rtCommandLineOptions $commandLine - * @param rtEnvironmentVariables $environmentVariables - * @return boolean - */ - public function check($commandLine, $environmentVariables) { - foreach($this->preConditions as $preCon) { - $p = new $preCon; - if(!$p->check($commandLine, $environmentVariables)) { - die($p->getMessage()); - } + return true; } - return true; - } + /** + * Test to ensure that a particular pre-condition exists (used in testing) + * + * @param string $pc + * @return boolean + */ + public function hasPreCondition($pc) + { + if(in_array($pc, $this->preConditions)) { + return true; + } - /** - * Test to ensure that a particular pre-condition exists (used in testing) - * - * @param string $pc - * @return boolean - */ - public function hasPreCondition($pc) { - if(in_array($pc, $this->preConditions)) { - return true; + return false; } - return false; - } - } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtRuntestsConfiguration.php b/src/configuration/rtRuntestsConfiguration.php index 03668a8..37a5b36 100644 --- a/src/configuration/rtRuntestsConfiguration.php +++ b/src/configuration/rtRuntestsConfiguration.php @@ -7,213 +7,195 @@ * */ -abstract class rtRuntestsConfiguration { - - private $settings; - private $setters; - private $environmentVariables; - private $commandLine; - protected $commandLineArgs; - - private $settingNames = array ( - - 'CurrentDirectory' => 'rtCurrentDirectorySetting', - 'LogFormat' => 'rtLogFormatSetting', - 'PhpExecutable' => 'rtPhpExecutableSetting', - 'PhpCgiExecutable' => 'rtPhpCgiExecutableSetting', - 'TestFiles' => 'rtTestFileSetting', - 'TestDirectories' => 'rtTestDirectorySetting', - 'WorkingDirectory' => 'rtWorkingDirectorySetting', - 'PhpCommandLineArguments' => 'rtPhpCommandLineArgSetting', - - ); - - - protected function init() { - //parse command line - $this->commandLine = new rtCommandLineOptions; - $this->commandLine->parse($this->commandLineArgs); +abstract class rtRuntestsConfiguration +{ + private $settings; + private $setters; + private $environmentVariables; + private $commandLine; + protected $commandLineArgs; + + private $settingNames = array ( + 'CurrentDirectory' => 'rtCurrentDirectorySetting', + 'LogFormat' => 'rtLogFormatSetting', + 'PhpExecutable' => 'rtPhpExecutableSetting', + 'PhpCgiExecutable' => 'rtPhpCgiExecutableSetting', + 'TestFiles' => 'rtTestFileSetting', + 'TestDirectories' => 'rtTestDirectorySetting', + 'WorkingDirectory' => 'rtWorkingDirectorySetting', + 'PhpCommandLineArguments' => 'rtPhpCommandLineArgSetting', + ); + + protected function init() + { + //parse command line + $this->commandLine = new rtCommandLineOptions; + $this->commandLine->parse($this->commandLineArgs); + + //get and put envrionment variables + $this->environmentVariables = rtEnvironmentVariables::getInstance(); + $this->environmentVariables->getUserSuppliedVariables(); + } - //get and put envrionment variables - $this->environmentVariables = rtEnvironmentVariables::getInstance(); - $this->environmentVariables->getUserSuppliedVariables(); - } + public function configure() + { + //extend test command line using TEST_PHP_ARGS + $options = new rtAddToCommandLine(); + $options->parseAdditionalOptions($this->commandLine, $this->environmentVariables); - public function configure() { + //check configuration preconditions + $preConditionList = rtPreConditionList::getInstance(); + $preConditionList->check($this->commandLine, $this->environmentVariables); - //extend test command line using TEST_PHP_ARGS - $options = new rtAddToCommandLine(); - $options->parseAdditionalOptions($this->commandLine, $this->environmentVariables); - //check configuration preconditions - $preConditionList = rtPreConditionList::getInstance(); - $preConditionList->check($this->commandLine, $this->environmentVariables); + //set configuration + foreach($this->settingNames as $name => $setting) { + $this->setters[$name] = new $setting($this); + } - //set configuration - foreach($this->settingNames as $name => $setting) { - $this->setters[$name] = new $setting($this); + foreach($this->settingNames as $name => $setting) { + $methodName = 'set' . $name; + $this->$methodName(); + } } - - foreach($this->settingNames as $name => $setting) { - $methodName = 'set' . $name; - $this->$methodName(); + /** + * Factory: returns rtRuntestsConfiguration subclass for the given os. + * + * @returns rtEnvironment + */ + static public function getInstance ($commandLineArgs, $os = 'Unix') + { + if ($os == 'Windows') { + return new rtWinConfiguration($commandLineArgs); + } else { + return new rtUnixConfiguration($commandLineArgs); + } } - } + /** + * Sets the directory that run-tests was started from + * + */ + private function setCurrentDirectory() { + $this->settings['CurrentDirectory']= $this->setters['CurrentDirectory']->get(); + } + /** + * Sets the directory that run-tests is run from + * + */ + private function setWorkingDirectory() { + $this->settings['WorkingDirectory']= $this->setters['WorkingDirectory']->get(); + } - /** - * Factory: returns rtRuntestsConfiguration subclass for the given os. - * - * @returns rtEnvironment - */ - public static function getInstance ($commandLineArgs, $os = 'Unix') - { - if ($os == 'Windows') { - return new rtWinConfiguration($commandLineArgs); - } else { - return new rtUnixConfiguration($commandLineArgs); + /** + * Sets the PHP executable being used to run teh tests + * + */ + private function setPhpExecutable() { + $this->settings['PhpExecutable']= $this->setters['PhpExecutable']->get(); } - } + /** + * Sets the PHP GGI executable being used to run the tests + * + */ + private function setPhpCgiExecutable() { + $this->settings['PhpCgiExecutable']= $this->setters['PhpCgiExecutable']->get(); + } - /** - * Sets the directory that run-tests was started from - * - */ - private function setCurrentDirectory() { - $this->settings['CurrentDirectory']= $this->setters['CurrentDirectory']->get(); - } + /** + * Sets the log format + * + */ + private function setLogFormat() { + $this->settings['LogFormat']= $this->setters['LogFormat']->get(); + } + /** + * Sets the command line arguments for PHP + * + */ + private function setPhpCommandLineArguments() { + $this->settings['PhpCommandLineArguments']= $this->setters['PhpCommandLineArguments']->get(); + } - /** - * Sets the directory that run-tests is run from - * - */ - private function setWorkingDirectory() { - $this->settings['WorkingDirectory']= $this->setters['WorkingDirectory']->get(); - } + /** + * Sets the names of directories to be tested + * + */ + private function setTestDirectories() { + $this->settings['TestDirectories'] = $this->setters['TestDirectories']->get(); + } + /** + * Sets the names of files to be tested + * + * @param array $testFiles + */ + private function setTestFiles() { + $this->settings['TestFiles'] = $this->setters['TestFiles']->get(); + } - /** - * Sets the PHP executable being used to run teh tests - * - */ - private function setPhpExecutable() { - $this->settings['PhpExecutable']= $this->setters['PhpExecutable']->get(); - } - - - /** - * Sets the PHP GGI executable being used to run the tests - * - */ - private function setPhpCgiExecutable() { - $this->settings['PhpCgiExecutable']= $this->setters['PhpCgiExecutable']->get(); + /** + * Returns the value of a setting + * + * @param string $settingName + * @param mixed (may be array or string) + */ - } + public function getSetting($settingName) { + return $this->settings[$settingName]; + } - /** - * Sets the log format - * - */ - private function setLogFormat() { - $this->settings['LogFormat']= $this->setters['LogFormat']->get(); - } - + /** + * Returns the entire settings array + * + * @return array $settings + */ + public function getSettings() { + return $this->settings; + } - /** - * Sets the command line arguments for PHP - * - */ - private function setPhpCommandLineArguments() { - $this->settings['PhpCommandLineArguments']= $this->setters['PhpCommandLineArguments']->get(); - } + public function getEnvironmentVariable($name) { + return $this->environmentVariables->getVariable($name); + } + + public function getEnvironmentVariables() { + return $this->environmentVariables->getVariables(); + } + public function hasCommandLineOption($option) { + return $this->commandLine->hasOption($option); + } - /** - * Sets the names of directories to be tested - * - */ - private function setTestDirectories() { - $this->settings['TestDirectories'] = $this->setters['TestDirectories']->get(); - } - - - /** - * Sets the names of files to be tested - * - * @param array $testFiles - */ - private function setTestFiles() { - $this->settings['TestFiles'] = $this->setters['TestFiles']->get(); - } - - - /** - * Returns the value of a setting - * - * @param string $settingName - * @param mixed (may be array or string) - */ - - public function getSetting($settingName) { - return $this->settings[$settingName]; - } - - - /** - * Returns the entire settings array - * - * @return array $settings - */ - public function getSettings() { - return $this->settings; - } - - public function getEnvironmentVariable($name) { - return $this->environmentVariables->getVariable($name); - } - - public function getEnvironmentVariables() { - return $this->environmentVariables->getVariables(); - } - - public function hasCommandLineOption($option) { - return $this->commandLine->hasOption($option); - } - - public function getCommandLineOption($option) { - return $this->commandLine->getOption($option); - } - - - public function hasEnvironmentVariable($name) { - return $this->environmentVariables->hasVariable($name); - } - - /** - * required for testing? - * - * @param unknown_type $name - * @param unknown_type $value - * @return unknown - */ - public function setEnvironmentVariable($name, $value) { - $this->environmentVariables->setVariable($name, $value); - } - - public function getTestFilename() { - return $this->commandLine->getTestFilename(); - } + public function getCommandLineOption($option) { + return $this->commandLine->getOption($option); + } + + public function hasEnvironmentVariable($name) { + return $this->environmentVariables->hasVariable($name); + } + /** + * required for testing? + * + * @param unknown_type $name + * @param unknown_type $value + * @return unknown + */ + public function setEnvironmentVariable($name, $value) { + $this->environmentVariables->setVariable($name, $value); + } + + public function getTestFilename() { + return $this->commandLine->getTestFilename(); + } } - - ?> diff --git a/src/configuration/rtSetting.php b/src/configuration/rtSetting.php index a7c6e5e..42dc71c 100644 --- a/src/configuration/rtSetting.php +++ b/src/configuration/rtSetting.php @@ -4,30 +4,23 @@ * Classes that set things in the test configuration * */ - - -abstract class rtSetting { - - - public function __construct(rtRuntestsConfiguration $configuration) { - $this->init($configuration); - } - - - - /** - * Sets a variable from command line options or environmental variables - * - */ - abstract public function init(rtRuntestsConfiguration $configuration); - - - /** - * Applies the setting to the global environment - * - * @param rtGlobalEnvironment $env - */ - abstract public function get(); - +abstract class rtSetting +{ + public function __construct(rtRuntestsConfiguration $configuration) { + $this->init($configuration); + } + + /** + * Sets a variable from command line options or environmental variables + * + */ + abstract public function init(rtRuntestsConfiguration $configuration); + + /** + * Applies the setting to the global environment + * + * @param rtGlobalEnvironment $env + */ + abstract public function get(); } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtCurrentDirectorySetting.php b/src/configuration/settings/rtCurrentDirectorySetting.php index dee4195..ec3f92e 100644 --- a/src/configuration/settings/rtCurrentDirectorySetting.php +++ b/src/configuration/settings/rtCurrentDirectorySetting.php @@ -4,26 +4,26 @@ * Class to set the directory at the start of the run * */ -class rtCurrentDirectorySetting extends rtSetting { +class rtCurrentDirectorySetting extends rtSetting +{ + private $currentDirectory; - private $currentDirectory; - - /** - * Set the current directory - * - */ - public function init(rtRuntestsConfiguration $configuration) { - $this->currentDirectory = getcwd(); - } - - - /** - * Return current directory setting to the configuration - * - */ - public function get() { - return $this->currentDirectory; - } + /** + * Set the current directory + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + $this->currentDirectory = getcwd(); + } + /** + * Return current directory setting to the configuration + * + */ + public function get() + { + return $this->currentDirectory; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtLogFormatSetting.php b/src/configuration/settings/rtLogFormatSetting.php index 5010b2d..1069b2c 100644 --- a/src/configuration/settings/rtLogFormatSetting.php +++ b/src/configuration/settings/rtLogFormatSetting.php @@ -4,35 +4,31 @@ * Sets the format of the log file * */ -class rtLogFormatSetting extends rtSetting { - - private $logFormat; - - - /** - * Sets log format to that specifiled by TEST_PHP_LOG_FORMAT or LEOD - * - */ - public function init(rtRuntestsConfiguration $configuration) { - - if ($configuration->hasEnvironmentVariable('TEST_PHP_LOG_FORMAT')) { - $this->logFormat = strtoupper($configuration->getEnvironmentVariable('TEST_PHP_LOG_FORMAT')); - } else { - $this->logFormat = 'LEOD'; - +class rtLogFormatSetting extends rtSetting +{ + private $logFormat; + + /** + * Sets log format to that specifiled by TEST_PHP_LOG_FORMAT or LEOD + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if ($configuration->hasEnvironmentVariable('TEST_PHP_LOG_FORMAT')) { + $this->logFormat = strtoupper($configuration->getEnvironmentVariable('TEST_PHP_LOG_FORMAT')); + } else { + $this->logFormat = 'LEOD'; + } } - } - - - /** - * Apply log format setting to the configuration - * - * - */ - public function get() { - return $this->logFormat; - } + /** + * Apply log format setting to the configuration + * + * + */ + public function get() + { + return $this->logFormat; + } } - ?> diff --git a/src/configuration/settings/rtPhpCgiExecutableSetting.php b/src/configuration/settings/rtPhpCgiExecutableSetting.php index fb83062..728b95c 100644 --- a/src/configuration/settings/rtPhpCgiExecutableSetting.php +++ b/src/configuration/settings/rtPhpCgiExecutableSetting.php @@ -4,44 +4,43 @@ * Class for setting the PHP CGI executable * */ -class rtPhpCgiExecutableSetting extends rtSetting{ - - private $phpCgiExecutable; - const SAPI_CGI = "/sapi/cgi/php"; - - - /** - * Sets the PHP CGI executable. Note the dependency on having a working directory setting - * - */ - public function init(rtRuntestsConfiguration $configuration) { +class rtPhpCgiExecutableSetting extends rtSetting +{ + const SAPI_CGI = "/sapi/cgi/php"; + + private $phpCgiExecutable; - if(is_null($configuration->getSetting('workingDirectory'))) { - $workingDir = 'WORKING_DIR'; - } else { - $workingDir = $configuration->getSetting('workingDirectory'); + /** + * Sets the PHP CGI executable. Note the dependency on having a working directory setting + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if (is_null($configuration->getSetting('workingDirectory'))) { + $workingDir = 'WORKING_DIR'; + } else { + $workingDir = $configuration->getSetting('workingDirectory'); + } + + if ($configuration->hasEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE')) { + if($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') { + $this->phpCgiExecutable = $workingDir . self::SAPI_CGI; + } else { + $this->phpCgiExecutable = $configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'); + } + } else { + $this->phpCgiExecutable = null; + } } - if ($configuration->hasEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE')) { - if($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') { - $this->phpCgiExecutable = $workingDir.self::SAPI_CGI; - } else { - $this->phpCgiExecutable = $configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'); - } - } else { - $this->phpCgiExecutable=null; - } - } - - - /** - * Supply the setting to the configuration on request - * - */ - public function get() { - return $this->phpCgiExecutable; - } - + + /** + * Supply the setting to the configuration on request + * + */ + public function get() + { + return $this->phpCgiExecutable; + } } - -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtPhpCommandLineArgSetting.php b/src/configuration/settings/rtPhpCommandLineArgSetting.php index dc14efd..d502d4d 100644 --- a/src/configuration/settings/rtPhpCommandLineArgSetting.php +++ b/src/configuration/settings/rtPhpCommandLineArgSetting.php @@ -1,38 +1,35 @@ <?php + /** * Sets the arguments to teh PHP command line, initially as ini overrides * converted to -d flags * */ -class rtPhpCommandLineArgSetting extends rtSetting { - - private $phpCommandLineArguments; - - - - /** - * Sets the command line arguments for - * - */ - public function init(rtRuntestsConfiguration $configuration) { - $iniArguments = new rtIniAsCommandLineArgs(); - $iniArguments->setBase(); - $this->phpCommandLineArguments = $iniArguments->getBasePhpDArgs(); +class rtPhpCommandLineArgSetting extends rtSetting +{ + private $phpCommandLineArguments; - if($configuration->hasCommandLineOption('n')) { - $this->phpCommandLineArguments = '-n ' . $this->phpCommandLineArguments; + /** + * Sets the command line arguments for + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + $iniArguments = new rtIniAsCommandLineArgs(); + $iniArguments->setBase(); + $this->phpCommandLineArguments = $iniArguments->getBasePhpDArgs(); + + if ($configuration->hasCommandLineOption('n')) { + $this->phpCommandLineArguments = '-n ' . $this->phpCommandLineArguments; + } + } + + /** + * Supply commandline arguments setting to the run configuration + * + */ + public function get() { + return $this->phpCommandLineArguments; } - - } - - - /** - * Supply commandline arguments setting to the run configuration - * - */ - public function get() { - return $this->phpCommandLineArguments; - } - } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtPhpExecutableSetting.php b/src/configuration/settings/rtPhpExecutableSetting.php index 0f51318..b24bc30 100644 --- a/src/configuration/settings/rtPhpExecutableSetting.php +++ b/src/configuration/settings/rtPhpExecutableSetting.php @@ -4,47 +4,46 @@ * Class to set the PHP executable to be tested * */ -class rtPhpExecutableSetting extends rtSetting{ - - private $phpExecutable; - - const SAPI_CLI = "/sapi/cli/php"; - - - /** - * Sets the PHP executable, note the dependency on working directory - * - */ - public function init(rtRuntestsConfiguration $configuration) { - - if(is_null($configuration->getSetting('workingDirectory'))) { - $workingDir = 'WORKING_DIR'; - } else { - $workingDir = $configuration->getSetting('workingDirectory'); - } +class rtPhpExecutableSetting extends rtSetting +{ + const SAPI_CLI = "/sapi/cli/php"; + + private $phpExecutable; - if ($configuration->hasEnvironmentVariable('TEST_PHP_EXECUTABLE')) { - if($configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE') == 'auto') { - $this->phpExecutable = $workingDir.self::SAPI_CLI; + /** + * Sets the PHP executable, note the dependency on working directory + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if (is_null($configuration->getSetting('workingDirectory'))) { + $workingDir = 'WORKING_DIR'; + } else { + $workingDir = $configuration->getSetting('workingDirectory'); + } + + if ($configuration->hasEnvironmentVariable('TEST_PHP_EXECUTABLE')) { - } else { - $this->phpExecutable = $configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE'); - } - } - if ($configuration->hasCommandLineOption('p')) { - $this->phpExecutable = $configuration->getCommandLineOption('p'); + if($configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE') == 'auto') { + $this->phpExecutable = $workingDir.self::SAPI_CLI; + } else { + $this->phpExecutable = $configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE'); + } + } + + if ($configuration->hasCommandLineOption('p')) { + $this->phpExecutable = $configuration->getCommandLineOption('p'); + } } - } - - - /** - * Supply the PHP executable setting to the configuration - * - */ - public function get() { - return $this->phpExecutable; - } - + + /** + * Supply the PHP executable setting to the configuration + * + */ + public function get() + { + return $this->phpExecutable; + } } ?> diff --git a/src/configuration/settings/rtTestDirectorySetting.php b/src/configuration/settings/rtTestDirectorySetting.php index 1d9bf56..6f572db 100644 --- a/src/configuration/settings/rtTestDirectorySetting.php +++ b/src/configuration/settings/rtTestDirectorySetting.php @@ -5,43 +5,44 @@ * to be tested and can be provided on teh command line or by TEST_PHP_USER * */ -class rtTestDirectorySetting extends rtSetting { - - private $testDir = null; +class rtTestDirectorySetting extends rtSetting +{ + private $testDir = null; + + /** + * Check each option - if it's a directory add it to the list. + * If not leave it. + * + * @param rtCommandLine $commandLine + * @param rtEnvironmentVariables $environmentVariables + */ + public function init(rtRuntestsConfiguration $configuration) + { + $fileArray = $configuration->getTestFilename(); - - /** - * Check each option - if it's a directory add it to the list. - * If not leave it. - * - * @param rtCommandLine $commandLine - * @param rtEnvironmentVariables $environmentVariables - */ - public function init(rtRuntestsConfiguration $configuration) { - $fileArray = $configuration->getTestFilename(); - foreach($fileArray as $file) { - if( is_dir($file)) { - $this->testDir[]= $file; - } - } - if($configuration->hasEnvironmentVariable('TEST_PHP_USER')) { - $fileArray = trim($configuration->getEnvironmentVariable('TEST_PHP_USER')); - foreach($fileArray as $file) { - if( is_dir($file)) { - $this->testDir[]= $file; + foreach($fileArray as $file) { + if( is_dir($file)) { + $this->testDir[]= $file; + } + } + + if($configuration->hasEnvironmentVariable('TEST_PHP_USER')) { + $fileArray = trim($configuration->getEnvironmentVariable('TEST_PHP_USER')); + foreach($fileArray as $file) { + if( is_dir($file)) { + $this->testDir[]= $file; + } + } } - } } - } - - - /** - * Set the test directory/directories list in the configuration - * - */ - public function get() { - return $this->testDir; - } - + + /** + * Set the test directory/directories list in the configuration + * + */ + public function get() + { + return $this->testDir; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtTestFileSetting.php b/src/configuration/settings/rtTestFileSetting.php index d45a1aa..1146663 100644 --- a/src/configuration/settings/rtTestFileSetting.php +++ b/src/configuration/settings/rtTestFileSetting.php @@ -5,52 +5,51 @@ * from the command line or as lists in files using the command line -r or -l options * */ -class rtTestFileSetting extends rtSetting { - - private $testFiles; +class rtTestFileSetting extends rtSetting +{ + private $testFiles; - /** - * Check each filename - if it's not a directory and the name ends .phpt - * add it to the list. Also read the -l and -r options and do the same checking with those - * - * @param rtCommandLine $commandLine - * - */ - public function init(rtRuntestsConfiguration $configuration) { - $fileArray = $configuration->getTestFilename(); - foreach($fileArray as $fn) { - if( !is_dir($fn) && substr( $fn, -5) == ".phpt") { - $this->testFiles[]= $fn; - } - } + /** + * Check each filename - if it's not a directory and the name ends .phpt + * add it to the list. Also read the -l and -r options and do the same checking with those + * + * @param rtCommandLine $commandLine + * + */ + public function init(rtRuntestsConfiguration $configuration) { + $fileArray = $configuration->getTestFilename(); - if($configuration->hasCommandLineOption('l')) { - $fileArray = file($configuration->getCommandLineOption('l')); - foreach($fileArray as $file) { - if(substr( trim($file), -5) == ".phpt") { - $this->testFiles[]= trim($file); + foreach($fileArray as $fn) { + if( !is_dir($fn) && substr($fn, -5) == ".phpt") { + $this->testFiles[] = $fn; + } + } + + if($configuration->hasCommandLineOption('l')) { + $fileArray = file($configuration->getCommandLineOption('l')); + foreach($fileArray as $file) { + if(substr(trim($file), -5) == ".phpt") { + $this->testFiles[] = trim($file); + } + } } - } - } - if($configuration->hasCommandLineOption('r')) { - $fileArray = file($configuration->getCommandLineOption('r')); - foreach($fileArray as $file) { - if(substr( trim($file), -5) == ".phpt") { - $this->testFiles[]= trim($file); + if($configuration->hasCommandLineOption('r')) { + $fileArray = file($configuration->getCommandLineOption('r')); + foreach($fileArray as $file) { + if(substr(trim($file), -5) == ".phpt") { + $this->testFiles[] = trim($file); + } + } } - } } - } - - /** - * Reurns a list of test files - * - */ - public function get() { - return $this->testFiles; - } + /** + * Reurns a list of test files + * + */ + public function get() { + return $this->testFiles; + } } - -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtWorkingDirectorySetting.php b/src/configuration/settings/rtWorkingDirectorySetting.php index 78f4912..2c3408c 100644 --- a/src/configuration/settings/rtWorkingDirectorySetting.php +++ b/src/configuration/settings/rtWorkingDirectorySetting.php @@ -5,33 +5,30 @@ * that run-tests.php was started from) * */ -class rtWorkingDirectorySetting extends rtSetting { - - private $workingDirectory; - - - - /** - * Sets the working directory - * - */ - public function init(rtRuntestsConfiguration $configuration) { - - if($configuration->hasEnvironmentVariable('TEST_PHP_SRCDIR')) { - $this->workingDirectory = $configuration->getEnvironmentVariable('TEST_PHP_SRCDIR'); - } else { - $this->workingDirectory = getcwd(); +class rtWorkingDirectorySetting extends rtSetting +{ + private $workingDirectory; + + /** + * Sets the working directory + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if($configuration->hasEnvironmentVariable('TEST_PHP_SRCDIR')) { + $this->workingDirectory = $configuration->getEnvironmentVariable('TEST_PHP_SRCDIR'); + } else { + $this->workingDirectory = getcwd(); + } } - } - - - /** - * Supply working directory to the configuration - * - */ - public function get() { - return $this->workingDirectory; - } - + + /** + * Supply working directory to the configuration + * + */ + public function get() + { + return $this->workingDirectory; + } } ?> diff --git a/src/rtDirectoryList.php b/src/rtDirectoryList.php index fb5352d..cd8fe50 100644 --- a/src/rtDirectoryList.php +++ b/src/rtDirectoryList.php @@ -7,21 +7,21 @@ */ class rtDirectoryList { - /** - * Finds a list of subdirectories under the top level ditectory and returns the full path names in an array - * - * @param string $topDirectory - * @return array - */ - public function getSubDirectoryPaths($topDirectory) - { - $result = array($topDirectory); - - foreach (new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($topDirectory)), 1) as $dir) { - $result[] = $dir->getPathName(); - } - - return $result; - } + /** + * Finds a list of subdirectories under the top level ditectory and returns the full path names in an array + * + * @param string $topDirectory + * @return array + */ + public function getSubDirectoryPaths($topDirectory) + { + $result = array($topDirectory); + + foreach (new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($topDirectory)), 1) as $dir) { + $result[] = $dir->getPathName(); + } + + return $result; + } } ?>
diff --git a/src/configuration/exceptions/rtEnvironmentException.php b/src/configuration/exceptions/rtEnvironmentException.php index e39bc01..c345081 100644 --- a/src/configuration/exceptions/rtEnvironmentException.php +++ b/src/configuration/exceptions/rtEnvironmentException.php @@ -1,7 +1,6 @@ <?php - class rtEnvironmentException extends RunTimeException - { - } - +class rtEnvironmentException extends RunTimeException +{ +} ?> diff --git a/src/configuration/exceptions/rtMissingArgumentException.php b/src/configuration/exceptions/rtMissingArgumentException.php index 048fb9a..5e90d36 100644 --- a/src/configuration/exceptions/rtMissingArgumentException.php +++ b/src/configuration/exceptions/rtMissingArgumentException.php @@ -1,7 +1,6 @@ <?php - class rtMissingArgumentException extends RuntimeException - { - } - +class rtMissingArgumentException extends RuntimeException +{ +} ?> diff --git a/src/configuration/exceptions/rtUnknownIniSettingException.php b/src/configuration/exceptions/rtUnknownIniSettingException.php index 2565e1b..f1ebe2c 100644 --- a/src/configuration/exceptions/rtUnknownIniSettingException.php +++ b/src/configuration/exceptions/rtUnknownIniSettingException.php @@ -1,7 +1,6 @@ <?php - class rtUnknownIniSettingException extends RuntimeException - { - } - +class rtUnknownIniSettingException extends RuntimeException +{ +} ?> diff --git a/src/configuration/exceptions/rtUnknownOptionException.php b/src/configuration/exceptions/rtUnknownOptionException.php index 9f9f5fb..4bb2c36 100644 --- a/src/configuration/exceptions/rtUnknownOptionException.php +++ b/src/configuration/exceptions/rtUnknownOptionException.php @@ -1,7 +1,6 @@ <?php - class rtUnknownOptionException extends RuntimeException - { - } - +class rtUnknownOptionException extends RuntimeException +{ +} ?> diff --git a/src/configuration/preconditions/rtIfParallelHasPcntl.php b/src/configuration/preconditions/rtIfParallelHasPcntl.php index f2801a1..e6f8f1f 100644 --- a/src/configuration/preconditions/rtIfParallelHasPcntl.php +++ b/src/configuration/preconditions/rtIfParallelHasPcntl.php @@ -4,31 +4,32 @@ * Class for checking whether the PCNTL extension is loaded * */ -class rtIfParallelHasPcntl extends rtPreCondition { - - - /** - * Return the message associated with missing PCRE - * - * @return text - */ - public function getMessage() { - return rtText::get('pcntlNotLoaded'); - } +class rtIfParallelHasPcntl extends rtPreCondition +{ + /** + * Return the message associated with missing PCRE + * + * @return text + */ + public function getMessage() + { + return rtText::get('pcntlNotLoaded'); + } + /** + * Check that the PCNTL is loaded if parallel run is required + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if ($commandLine->hasOption('z') || $environmentVariables->hasVariable('TESTS_PHP_PARALLEL')) { + if (!extension_loaded('pcntl')) { + return false; + } + } - /** - * Check that the PCNTL is loaded if parallel run is required - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if($commandLine->hasOption('z') || $environmentVariables->hasVariable('TESTS_PHP_PARALLEL')) { - if(!extension_loaded('pcntl')) { - return false; - } + return true; } - return true; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsExecutableSet.php b/src/configuration/preconditions/rtIsExecutableSet.php index 0cd2cc3..836ae94 100644 --- a/src/configuration/preconditions/rtIsExecutableSet.php +++ b/src/configuration/preconditions/rtIsExecutableSet.php @@ -4,35 +4,36 @@ * Class for checking whether a PHP Executable has been set * */ -class rtIsExecutableSet extends rtPreCondition { - - - /** - * Return the message associated with a missing PHP executable - * - * @return text - */ - public function getMessage() { - return rtText::get('missingPHPExecutable'); - } - - - /** - * Check that the PHP executable is a valid executable - * - * @param rtCommandLine $commandLine - * @param rtEnvironmentVariables $environment - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if($commandLine->hasOption('p')) { - return true; - } - if($environmentVariables->hasVariable('TEST_PHP_EXECUTABLE')) { - return true; +class rtIsExecutableSet extends rtPreCondition +{ + /** + * Return the message associated with a missing PHP executable + * + * @return text + */ + public function getMessage() + { + return rtText::get('missingPHPExecutable'); } - return false; - } - + + /** + * Check that the PHP executable is a valid executable + * + * @param rtCommandLine $commandLine + * @param rtEnvironmentVariables $environment + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if ($commandLine->hasOption('p')) { + return true; + } + + if ($environmentVariables->hasVariable('TEST_PHP_EXECUTABLE')) { + return true; + } + + return false; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsPcreLoaded.php b/src/configuration/preconditions/rtIsPcreLoaded.php index e5ed5dc..78acc7f 100644 --- a/src/configuration/preconditions/rtIsPcreLoaded.php +++ b/src/configuration/preconditions/rtIsPcreLoaded.php @@ -3,29 +3,30 @@ * Class for checking whether the PCRE extension is loaded * */ -class rtIsPcreLoaded extends rtPreCondition { +class rtIsPcreLoaded extends rtPreCondition +{ + /** + * Return the message associated with missing PCRE + * + * @return text + */ + public function getMessage() + { + return rtText::get('pcreNotLoaded'); + } - - /** - * Return the message associated with missing PCRE - * - * @return text - */ - public function getMessage() { - return rtText::get('pcreNotLoaded'); - } - - - /** - * Check that the PCRE is loaded - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if(extension_loaded('pcre')) { - return true; + /** + * Check that the PCRE is loaded + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if (extension_loaded('pcre')) { + return true; + } + + return false; } - return false; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsProcOpenAvailable.php b/src/configuration/preconditions/rtIsProcOpenAvailable.php index e469b35..21bc802 100644 --- a/src/configuration/preconditions/rtIsProcOpenAvailable.php +++ b/src/configuration/preconditions/rtIsProcOpenAvailable.php @@ -4,29 +4,30 @@ * Class for checking whether proc_open() is available * */ -class rtIsProcOpenAvailable extends rtPreCondition { +class rtIsProcOpenAvailable extends rtPreCondition +{ + /** + * Return the message associated with missing proc_open(); + * + * @return text + */ + public function getMessage() + { + return rtText::get('procOpenNotAvailable'); + } + + /** + * Check that proc_open() is available + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if (function_exists('proc_open')) { + return true; + } - - /** - * Return the message associated with missing proc_open(); - * - * @return text - */ - public function getMessage() { - return rtText::get('procOpenNotAvailable'); - } - - - /** - * Check that proc_open() is available - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if(function_exists('proc_open')) { - return true; + return false; } - return false; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsSafeModeDisabled.php b/src/configuration/preconditions/rtIsSafeModeDisabled.php index 112d17d..d12d6d0 100644 --- a/src/configuration/preconditions/rtIsSafeModeDisabled.php +++ b/src/configuration/preconditions/rtIsSafeModeDisabled.php @@ -4,29 +4,30 @@ * Class for checking if safe_mode is enabled * */ -class rtIsSafeModeDisabled extends rtPreCondition { - - - /** - * Return the message associated with safe mode enabled - * - * @return text - */ - public function getMessage() { - return rtText::get('safeModeNotDisabled'); - } +class rtIsSafeModeDisabled extends rtPreCondition +{ + /** + * Return the message associated with safe mode enabled + * + * @return text + */ + public function getMessage() + { + return rtText::get('safeModeNotDisabled'); + } + /** + * Check to see if safe mode is enabled + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if (!ini_get('safe_mode')) { + return true; + } - /** - * Check to see if safe mode is enabled - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if(!ini_get('safe_mode')) { - return true; + return false; } - return false; - } } -?> \ No newline at end of file +?> diff --git a/src/configuration/preconditions/rtIsTestFileSpecified.php b/src/configuration/preconditions/rtIsTestFileSpecified.php index 12b0c48..bdf79eb 100644 --- a/src/configuration/preconditions/rtIsTestFileSpecified.php +++ b/src/configuration/preconditions/rtIsTestFileSpecified.php @@ -4,41 +4,44 @@ * Class for checking that a test file, or directory has been specified * */ -class rtIsTestFileSpecified extends rtPreCondition { - - - /** - * Return the message associated with a missing PHP test file - * - * @return text - */ - public function getMessage() { - return rtText::get('missingTestFile'); - } - - - /** - * Check that a test file or directory has been given - * - * @param rtCommandLine $commandLine - * @param rtEnvironmentVariables $environmentVariables - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - if($commandLine->hasOption('l')) { - return true; - } - if($commandLine->hasOption('r')) { - return true; - } - if($commandLine->getTestFilename() != null) { - return true; +class rtIsTestFileSpecified extends rtPreCondition +{ + /** + * Return the message associated with a missing PHP test file + * + * @return text + */ + public function getMessage() + { + return rtText::get('missingTestFile'); } - if($environmentVariables->hasVariable('TEST_PHP_USER')) { - return true; - } - return false; - } - + + /** + * Check that a test file or directory has been given + * + * @param rtCommandLine $commandLine + * @param rtEnvironmentVariables $environmentVariables + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + if($commandLine->hasOption('l')) { + return true; + } + + if($commandLine->hasOption('r')) { + return true; + } + + if($commandLine->getTestFilename() != null) { + return true; + } + + if($environmentVariables->hasVariable('TEST_PHP_USER')) { + return true; + } + + return false; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtAddToCommandLine.php b/src/configuration/rtAddToCommandLine.php index 14ea700..89f9717 100644 --- a/src/configuration/rtAddToCommandLine.php +++ b/src/configuration/rtAddToCommandLine.php @@ -5,22 +5,20 @@ * that additional arguments are parsed * */ -class rtAddToCommandLine { - - - /** - * Parse additional values if supplied by env variable - * - * @param rtCommandLineOptions $commandLine - * @param rtEnvironmentVariables $environmentVariables - */ - public static function parseAdditionalOptions($commandLine, $environmentVariables) { - - if ($environmentVariables->hasVariable('TEST_PHP_ARGS')) { - $additionalOptions = array_merge(array('run-test.php'), explode(" ", $environmentVariables->getVariable('TEST_PHP_ARGS'))); - $commandLine->parse($additionalOptions); - } - } - +class rtAddToCommandLine +{ + /** + * Parse additional values if supplied by env variable + * + * @param rtCommandLineOptions $commandLine + * @param rtEnvironmentVariables $environmentVariables + */ + public static function parseAdditionalOptions($commandLine, $environmentVariables) + { + if ($environmentVariables->hasVariable('TEST_PHP_ARGS')) { + $additionalOptions = array_merge(array('run-test.php'), explode(" ", $environmentVariables->getVariable('TEST_PHP_ARGS'))); + $commandLine->parse($additionalOptions); + } + } } ?> diff --git a/src/configuration/rtCommandLineOptions.php b/src/configuration/rtCommandLineOptions.php index c036232..4a42880 100644 --- a/src/configuration/rtCommandLineOptions.php +++ b/src/configuration/rtCommandLineOptions.php @@ -10,200 +10,181 @@ */ class rtCommandLineOptions { -/** - * - */ - protected $shortOptions = array( - 'n', - 'm', - 'q', - 'x', - 'v', - 'h', - 'z', //parallel - run out of obvious letters - ); - - protected $shortOptionsWithArgs = array( - 'l', - 'r', - 'w', - 'a', - 'c', - 'd', - 'p', - 's', - ); - - protected $longOptions = array( - 'verbose', - 'help', - 'keep-all', - 'keep-php', - 'keep-skip', - 'keep-clean', - 'keep-out', - 'keep-exp', - 'show-all', - 'show-php', - 'show-skip', - 'show-clean', - 'show-exp', - 'show-diff', - 'show-out', - 'no-clean', - ); - - protected $longOptionsWithArgs = array( - 'html', - 'temp-source', - 'temp-target', - 'set-timeout', - ); + /** + * + */ + protected $shortOptions = array( + 'n', + 'm', + 'q', + 'x', + 'v', + 'h', + 'z', //parallel - run out of obvious letters + ); + + protected $shortOptionsWithArgs = array( + 'l', + 'r', + 'w', + 'a', + 'c', + 'd', + 'p', + 's', + ); + + protected $longOptions = array( + 'verbose', + 'help', + 'keep-all', + 'keep-php', + 'keep-skip', + 'keep-clean', + 'keep-out', + 'keep-exp', + 'show-all', + 'show-php', + 'show-skip', + 'show-clean', + 'show-exp', + 'show-diff', + 'show-out', + 'no-clean', + ); + + protected $longOptionsWithArgs = array( + 'html', + 'temp-source', + 'temp-target', + 'set-timeout', + ); - protected $options = array(); - - protected $testFilename = array(); - - /** - * Enter description here... - * - */ + protected $options = array(); - public function __construct() - { - } + protected $testFilename = array(); + public function __construct() + { + } - public function parse($argv) - { - $this->parseCommandLineOptions($this->stripSpaces($argv)); - } - - - protected function isShortOption($arg) - { - return (substr($arg, 0, 1) == '-') && (substr($arg, 1, 1) != '-'); - } + public function parse($argv) + { + $this->parseCommandLineOptions($this->stripSpaces($argv)); + } + protected function isShortOption($arg) + { + return (substr($arg, 0, 1) == '-') && (substr($arg, 1, 1) != '-'); + } - protected function isLongOption($arg) - { - return substr($arg, 0, 2) == '--'; - } - - - /** - * Parse command line, expects to find: - * -{shortOption} - * -{shortOptionWithArg} {arg} - * --{longOption} - * --{longOptionWithArg} {arg} - * file name|directory name - */ - public function parseCommandLineOptions($argv) - { - for ($i=0; $i<count($argv); $i++) + protected function isLongOption($arg) { + return substr($arg, 0, 2) == '--'; + } - if (!$this->isShortOption($argv[$i]) && !$this->isLongOption($argv[$i])) - { - $this->testFilename[] = $argv[$i]; - continue; + /** + * Parse command line, expects to find: + * -{shortOption} + * -{shortOptionWithArg} {arg} + * --{longOption} + * --{longOptionWithArg} {arg} + * file name|directory name + */ + public function parseCommandLineOptions($argv) + { + for ($i=0; $i<count($argv); $i++) { + + if (!$this->isShortOption($argv[$i]) && !$this->isLongOption($argv[$i])) { + $this->testFilename[] = $argv[$i]; + continue; + } + + if ($this->isShortOption($argv[$i])) { + $option = substr($argv[$i], 1); + } else { + $option = substr($argv[$i], 2); + } + + if (!in_array($option, array_merge($this->shortOptions, $this->shortOptionsWithArgs, $this->longOptions, $this->longOptionsWithArgs))) { + throw new rtUnknownOptionException('Unknown option ' . $argv[$i]); + } + + if (in_array($option, array_merge($this->shortOptions, $this->longOptions))) { + $this->options[$option] = true; + continue; + } + + if (!$this->isValidOptionArg($argv, $i + 1)) { + throw new rtMissingArgumentException('Missing argument for command line option ' . $argv[$i]); + } + + $i++; + $this->options[$option] = $argv[$i]; } + } - if ($this->isShortOption($argv[$i])) - { - $option = substr($argv[$i], 1); - } else { - $option = substr($argv[$i], 2); - } - if (!in_array($option, array_merge($this->shortOptions, $this->shortOptionsWithArgs, $this->longOptions, $this->longOptionsWithArgs))) - { - throw new rtUnknownOptionException('Unknown option ' . $argv[$i]); + /** + * Checks to make sure that the arument following does not begin with "-" + * @param string - argument + * @return bool + */ + public function isValidOptionArg($array, $index) + { + if (!isset($array[$index])) { + return false; } + return substr($array[$index], 0, 1) != '-'; + } - if (in_array($option, array_merge($this->shortOptions, $this->longOptions))) - { - $this->options[$option] = true; - continue; - } - if (!$this->isValidOptionArg($argv, $i + 1)) - { - throw new rtMissingArgumentException('Missing argument for command line option ' . $argv[$i]); - } + /** + * Removes spaces in command line arguments AND strips $argv[0] + * @param array - command line arguments + * @return array - command line args with blank entries removed + */ + protected function stripSpaces($argv) + { + $result = array(); - $i++; - $this->options[$option] = $argv[$i]; + for ($i=1; $i<count($argv); $i++) { + if ($argv[$i] != "") { + $result[] = $argv[$i]; + } + } + return $result; } - } - /** - * Checks to make sure that the arument following does not begin with "-" - * @param string - argument - * @return bool - */ - public function isValidOptionArg($array, $index) - { - if (!isset($array[$index])) + /** + * + */ + public function getOption($option) { - return false; - } - return substr($array[$index], 0, 1) != '-'; - } + if (!isset($this->options[$option])) { + return false; + } + return $this->options[$option]; + } - /** - * Removes spaces in command line arguments AND strips $argv[0] - * @param array - command line arguments - * @return array - command line args with blank entries removed - */ - protected function stripSpaces($argv) - { - $result = array(); - for ($i=1; $i<count($argv); $i++) + /** + * Check whether an option exists + */ + public function hasOption($option) { - if ($argv[$i] != "") { - $result[] = $argv[$i]; - } + return isset($this->options[$option]); } - return $result; - } - /** - * - */ - public function getOption($option) - { - if (!isset($this->options[$option])) { - return false; + /** + * Return the array containing file names or directory names to be tested + */ + public function getTestFilename() + { + return $this->testFilename; } - return $this->options[$option]; - } - - - /** - * Check whether an option exists - */ - public function hasOption($option) - { - return isset($this->options[$option]); - } - - - /** - * Return the array containing file names or directory names to be tested - */ - public function getTestFilename() - { - return $this->testFilename; - } - - } - ?> diff --git a/src/configuration/rtEnvironmentVariables.php b/src/configuration/rtEnvironmentVariables.php index e33c6bc..227ab0a 100644 --- a/src/configuration/rtEnvironmentVariables.php +++ b/src/configuration/rtEnvironmentVariables.php @@ -5,68 +5,71 @@ * Needs some changes - don't document till complete * */ -class rtEnvironmentVariables { +class rtEnvironmentVariables +{ + protected $userSuppliedVariables = array ( + 'TEST_PHP_EXECUTABLE', + 'TEST_PHP_SRCDIR', + 'TEST_PHP_CGI_EXECUTABLE', + 'TEST_PHP_LOG_FORMAT', + 'TEST_PHP_DETAILED', + 'TEST_PHP_USER', + 'NO_INTERACTION', + 'PHP_AUTOCONF', + 'TEST_PHP_ARGS', + 'REPORT_EXIT_STATUS', + 'TEST_PHP_ERROR_STYLE', + 'NO_PHPTEST_SUMMARY', + ); - protected $userSuppliedVariables = array ( - 'TEST_PHP_EXECUTABLE', - 'TEST_PHP_SRCDIR', - 'TEST_PHP_CGI_EXECUTABLE', - 'TEST_PHP_LOG_FORMAT', - 'TEST_PHP_DETAILED', - 'TEST_PHP_USER', - 'NO_INTERACTION', - 'PHP_AUTOCONF', - 'TEST_PHP_ARGS', - 'REPORT_EXIT_STATUS', - 'TEST_PHP_ERROR_STYLE', - 'NO_PHPTEST_SUMMARY', - ); + private $environmentVariables; - private $environmentVariables; - - public function __construct() { - - } + public function __construct() + { + } - public static function getInstance ($os = 'Unix') - { - if ($os == 'Windows') { - return new rtWinEnvironmentVariables(); - } else { - return new rtUnixEnvironmentVariables(); + static public function getInstance ($os = 'Unix') + { + if ($os == 'Windows') { + return new rtWinEnvironmentVariables(); + } else { + return new rtUnixEnvironmentVariables(); + } } - } + public function getUserSuppliedVariables() + { + if (isset($_ENV)) { + $this->environmentVariables = $_ENV; + } else { + $this->environmentVariables = array(); + } - public function getUserSuppliedVariables() { - if (isset($_ENV)) { - $this->environmentVariables = $_ENV; - } else { - $this->environmentVariables = array(); + foreach($this->userSuppliedVariables as $variable) { + if(getenv($variable)) { + $this->environmentVariables[$variable] = getenv($variable); + } + } } - foreach($this->userSuppliedVariables as $variable) { - if(getenv($variable)) { - $this->environmentVariables[$variable] = getenv($variable); - } + public function setVariable($var,$value) + { + $this->environmentVariables[$var] = $value; } - } - public function setVariable($var,$value) { - $this->environmentVariables[$var] = $value; - } - - public function getVariable($var) { - return $this->environmentVariables[$var]; - } - - public function hasVariable($var) { - return (isset ($this->environmentVariables[$var])); - } - - public function getVariables() { - return $this->environmentVariables; - } + public function getVariable($var) + { + return $this->environmentVariables[$var]; + } + public function hasVariable($var) + { + return (isset ($this->environmentVariables[$var])); + } + + public function getVariables() + { + return $this->environmentVariables; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtIniAsCommandLineArgs.php b/src/configuration/rtIniAsCommandLineArgs.php index 2307488..1951b6a 100644 --- a/src/configuration/rtIniAsCommandLineArgs.php +++ b/src/configuration/rtIniAsCommandLineArgs.php @@ -1,103 +1,118 @@ <?php -class rtIniAsCommandLineArgs { - protected $iniOverwrites = array( - 'output_handler=', - 'open_basedir=', - 'safe_mode=0', - 'disable_functions=', - 'output_buffering=Off', - "error_reporting= 32767", - 'display_errors=1', - 'display_startup_errors=1', - 'log_errors=0', - 'html_errors=0', - 'track_errors=1', - 'report_memleaks=1', - 'report_zend_debug=0', - 'docref_root=', - 'docref_ext=.html', - 'error_prepend_string=', - 'error_append_string=', - 'auto_prepend_file=', - 'auto_append_file=', - 'magic_quotes_runtime=0', - 'ignore_repeated_errors=0', - 'unicode.runtime_encoding=ISO-8859-1', - 'unicode.script_encoding=UTF-8', - 'unicode.output_encoding=UTF-8', - 'unicode.from_error_mode=U_INVALID_SUBSTITUTE', - ); +class rtIniAsCommandLineArgs +{ + protected $iniOverwrites = array( + 'output_handler=', + 'open_basedir=', + 'safe_mode=0', + 'disable_functions=', + 'output_buffering=Off', + "error_reporting= 32767", + 'display_errors=1', + 'display_startup_errors=1', + 'log_errors=0', + 'html_errors=0', + 'track_errors=1', + 'report_memleaks=1', + 'report_zend_debug=0', + 'docref_root=', + 'docref_ext=.html', + 'error_prepend_string=', + 'error_append_string=', + 'auto_prepend_file=', + 'auto_append_file=', + 'magic_quotes_runtime=0', + 'ignore_repeated_errors=0', + 'unicode.runtime_encoding=ISO-8859-1', + 'unicode.script_encoding=UTF-8', + 'unicode.output_encoding=UTF-8', + 'unicode.from_error_mode=U_INVALID_SUBSTITUTE', + ); - protected $basePhpDArgs; + protected $basePhpDArgs; - /** - * - */ - public function setBase() { - $this->basePhpDArgs=$this->settingsToArguments($this->iniOverwrites); - } - /** - * Sets the -d flags used in the PHP command that executes the PHP - * code from a test case - * @param array - ini settings - * @param string - command line arguments to be extended - * @return string - command line arguments - * - */ - public function settingsToArguments($array, $args="") { - foreach($array as $setting) { - if($this->isValidSetting($setting)) { - $setting=$this->stripSpaces($setting); - $args.=" -d \"$setting\""; - } else { - throw new rtUnknownIniSettingException("Invalid INI setting $setting"); - } + /** + * + */ + public function setBase() + { + $this->basePhpDArgs = $this->settingsToArguments($this->iniOverwrites); } - return $args; - } - /** - * Checks that the ini setting is valid - * - * @param string - ini setting in the form a=b - * @return boolean - false if not in expected format - */ - public function isValidSetting($string) { - $parts = explode("=", $string, 2); - //explode failed - if ($parts[0] === $string) {return false;} + /** + * Sets the -d flags used in the PHP command that executes the PHP + * code from a test case + * @param array - ini settings + * @param string - command line arguments to be extended + * @return string - command line arguments + * + */ + public function settingsToArguments($array, $args="") + { + foreach($array as $setting) { + if($this->isValidSetting($setting)) { + $setting = $this->stripSpaces($setting); + $args .= " -d \"$setting\""; + } else { + throw new rtUnknownIniSettingException("Invalid INI setting $setting"); + } + } - //test for == - if(strncmp($parts[1], '=', 1) === 0) {return false;} + return $args; + } + + /** + * Checks that the ini setting is valid + * + * @param string - ini setting in the form a=b + * @return boolean - false if not in expected format + */ + public function isValidSetting($string) + { + $parts = explode("=", $string, 2); + + //explode failed + if ($parts[0] === $string) { + return false; + } - //test for a=b=c - if(strstr($parts[1], '=') == false) { - return true; - }else { - return false; + //test for == + if(strncmp($parts[1], '=', 1) === 0) { + return false; + } + + //test for a=b=c + if(strstr($parts[1], '=') == false) { + return true; + } else { + return false; + } } - } - /** - * Removes spaces from ini settings, "a = b" is retirned as "a=b" - * - * @param string - ini setting - * @return string - ini setting with any spaces removed - */ - public function stripSpaces($string){ - $noSpace=""; - $parts = explode("=",$string, 2); - $noSpace.=trim($parts[0])."=".trim($parts[1]); - return $noSpace; - } - /** - * Returns an array containing the PHP test execution flags - * - * @return unknown - */ - public function getBasePhpDArgs() { - return $this->basePhpDArgs; - } -} + /** + * Removes spaces from ini settings, "a = b" is retirned as "a=b" + * + * @param string - ini setting + * @return string - ini setting with any spaces removed + */ + public function stripSpaces($string) + { + $noSpace = ""; + $parts = explode("=", $string, 2); + $noSpace .= trim($parts[0]) . "=" . trim($parts[1]); + + return $noSpace; + } + + /** + * Returns an array containing the PHP test execution flags + * + * @return unknown + */ + public function getBasePhpDArgs() + { + return $this->basePhpDArgs; + } +} ?> diff --git a/src/configuration/rtPreCondition.php b/src/configuration/rtPreCondition.php index 6e582d8..4c47def 100644 --- a/src/configuration/rtPreCondition.php +++ b/src/configuration/rtPreCondition.php @@ -3,24 +3,24 @@ /** * A pre-condtion for running a test */ -class rtPreCondition { - - - /** - * The message to use if teh pre-condition is not met - * - */ - public function getMessage() { - } - - /** - * Code to check the pre-condition - * - * @return boolean - */ - public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) { - return true; - } +class rtPreCondition +{ + /** + * The message to use if teh pre-condition is not met + * + */ + public function getMessage() + { + } + /** + * Code to check the pre-condition + * + * @return boolean + */ + public function check(rtCommandLineOptions $commandLine = null, rtEnvironmentVariables $environmentVariables = null) + { + return true; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtPreConditionList.php b/src/configuration/rtPreConditionList.php index c1e763a..2eab2e7 100644 --- a/src/configuration/rtPreConditionList.php +++ b/src/configuration/rtPreConditionList.php @@ -5,63 +5,62 @@ * platform run-tests is executed on * */ -abstract class rtPreConditionList { +abstract class rtPreConditionList +{ + protected $preConditions = array ( + 'rtIsExecutableSet', + 'rtIsPcreLoaded', + 'rtIsProcOpenAvailable', + 'rtIsSafeModeDisabled', + 'rtIsTestFileSpecified', + ); - protected $preConditions = array ( - 'rtIsExecutableSet', - 'rtIsPcreLoaded', - 'rtIsProcOpenAvailable', - 'rtIsSafeModeDisabled', - 'rtIsTestFileSpecified', - ); - - - /** - * Gets instance of a platform specific pre-condition list - * - * @param string $os - * @return rtPreConditionList Platform specific pre-condition list - */ - public static function getInstance ($os = 'Unix') - { - if ($os == 'Windows') { - return new rtWinPreconditionList('Windows'); - } else { - return new rtUnixPreConditionList(); + /** + * Gets instance of a platform specific pre-condition list + * + * @param string $os + * @return rtPreConditionList Platform specific pre-condition list + */ + static public function getInstance($os = 'Unix') + { + if ($os == 'Windows') { + return new rtWinPreconditionList('Windows'); + } else { + return new rtUnixPreConditionList(); + } } - } + /** + * Checks the validity of each pre-condition in the list + * + * @param rtCommandLineOptions $commandLine + * @param rtEnvironmentVariables $environmentVariables + * @return boolean + */ + public function check($commandLine, $environmentVariables) { + foreach($this->preConditions as $preCon) { + $p = new $preCon; + if(!$p->check($commandLine, $environmentVariables)) { + die($p->getMessage()); + } + } - /** - * Checks the validity of each pre-condition in the list - * - * @param rtCommandLineOptions $commandLine - * @param rtEnvironmentVariables $environmentVariables - * @return boolean - */ - public function check($commandLine, $environmentVariables) { - foreach($this->preConditions as $preCon) { - $p = new $preCon; - if(!$p->check($commandLine, $environmentVariables)) { - die($p->getMessage()); - } + return true; } - return true; - } + /** + * Test to ensure that a particular pre-condition exists (used in testing) + * + * @param string $pc + * @return boolean + */ + public function hasPreCondition($pc) + { + if(in_array($pc, $this->preConditions)) { + return true; + } - /** - * Test to ensure that a particular pre-condition exists (used in testing) - * - * @param string $pc - * @return boolean - */ - public function hasPreCondition($pc) { - if(in_array($pc, $this->preConditions)) { - return true; + return false; } - return false; - } - } -?> \ No newline at end of file +?> diff --git a/src/configuration/rtRuntestsConfiguration.php b/src/configuration/rtRuntestsConfiguration.php index 03668a8..37a5b36 100644 --- a/src/configuration/rtRuntestsConfiguration.php +++ b/src/configuration/rtRuntestsConfiguration.php @@ -7,213 +7,195 @@ * */ -abstract class rtRuntestsConfiguration { - - private $settings; - private $setters; - private $environmentVariables; - private $commandLine; - protected $commandLineArgs; - - private $settingNames = array ( - - 'CurrentDirectory' => 'rtCurrentDirectorySetting', - 'LogFormat' => 'rtLogFormatSetting', - 'PhpExecutable' => 'rtPhpExecutableSetting', - 'PhpCgiExecutable' => 'rtPhpCgiExecutableSetting', - 'TestFiles' => 'rtTestFileSetting', - 'TestDirectories' => 'rtTestDirectorySetting', - 'WorkingDirectory' => 'rtWorkingDirectorySetting', - 'PhpCommandLineArguments' => 'rtPhpCommandLineArgSetting', - - ); - - - protected function init() { - //parse command line - $this->commandLine = new rtCommandLineOptions; - $this->commandLine->parse($this->commandLineArgs); +abstract class rtRuntestsConfiguration +{ + private $settings; + private $setters; + private $environmentVariables; + private $commandLine; + protected $commandLineArgs; + + private $settingNames = array ( + 'CurrentDirectory' => 'rtCurrentDirectorySetting', + 'LogFormat' => 'rtLogFormatSetting', + 'PhpExecutable' => 'rtPhpExecutableSetting', + 'PhpCgiExecutable' => 'rtPhpCgiExecutableSetting', + 'TestFiles' => 'rtTestFileSetting', + 'TestDirectories' => 'rtTestDirectorySetting', + 'WorkingDirectory' => 'rtWorkingDirectorySetting', + 'PhpCommandLineArguments' => 'rtPhpCommandLineArgSetting', + ); + + protected function init() + { + //parse command line + $this->commandLine = new rtCommandLineOptions; + $this->commandLine->parse($this->commandLineArgs); + + //get and put envrionment variables + $this->environmentVariables = rtEnvironmentVariables::getInstance(); + $this->environmentVariables->getUserSuppliedVariables(); + } - //get and put envrionment variables - $this->environmentVariables = rtEnvironmentVariables::getInstance(); - $this->environmentVariables->getUserSuppliedVariables(); - } + public function configure() + { + //extend test command line using TEST_PHP_ARGS + $options = new rtAddToCommandLine(); + $options->parseAdditionalOptions($this->commandLine, $this->environmentVariables); - public function configure() { + //check configuration preconditions + $preConditionList = rtPreConditionList::getInstance(); + $preConditionList->check($this->commandLine, $this->environmentVariables); - //extend test command line using TEST_PHP_ARGS - $options = new rtAddToCommandLine(); - $options->parseAdditionalOptions($this->commandLine, $this->environmentVariables); - //check configuration preconditions - $preConditionList = rtPreConditionList::getInstance(); - $preConditionList->check($this->commandLine, $this->environmentVariables); + //set configuration + foreach($this->settingNames as $name => $setting) { + $this->setters[$name] = new $setting($this); + } - //set configuration - foreach($this->settingNames as $name => $setting) { - $this->setters[$name] = new $setting($this); + foreach($this->settingNames as $name => $setting) { + $methodName = 'set' . $name; + $this->$methodName(); + } } - - foreach($this->settingNames as $name => $setting) { - $methodName = 'set' . $name; - $this->$methodName(); + /** + * Factory: returns rtRuntestsConfiguration subclass for the given os. + * + * @returns rtEnvironment + */ + static public function getInstance ($commandLineArgs, $os = 'Unix') + { + if ($os == 'Windows') { + return new rtWinConfiguration($commandLineArgs); + } else { + return new rtUnixConfiguration($commandLineArgs); + } } - } + /** + * Sets the directory that run-tests was started from + * + */ + private function setCurrentDirectory() { + $this->settings['CurrentDirectory']= $this->setters['CurrentDirectory']->get(); + } + /** + * Sets the directory that run-tests is run from + * + */ + private function setWorkingDirectory() { + $this->settings['WorkingDirectory']= $this->setters['WorkingDirectory']->get(); + } - /** - * Factory: returns rtRuntestsConfiguration subclass for the given os. - * - * @returns rtEnvironment - */ - public static function getInstance ($commandLineArgs, $os = 'Unix') - { - if ($os == 'Windows') { - return new rtWinConfiguration($commandLineArgs); - } else { - return new rtUnixConfiguration($commandLineArgs); + /** + * Sets the PHP executable being used to run teh tests + * + */ + private function setPhpExecutable() { + $this->settings['PhpExecutable']= $this->setters['PhpExecutable']->get(); } - } + /** + * Sets the PHP GGI executable being used to run the tests + * + */ + private function setPhpCgiExecutable() { + $this->settings['PhpCgiExecutable']= $this->setters['PhpCgiExecutable']->get(); + } - /** - * Sets the directory that run-tests was started from - * - */ - private function setCurrentDirectory() { - $this->settings['CurrentDirectory']= $this->setters['CurrentDirectory']->get(); - } + /** + * Sets the log format + * + */ + private function setLogFormat() { + $this->settings['LogFormat']= $this->setters['LogFormat']->get(); + } + /** + * Sets the command line arguments for PHP + * + */ + private function setPhpCommandLineArguments() { + $this->settings['PhpCommandLineArguments']= $this->setters['PhpCommandLineArguments']->get(); + } - /** - * Sets the directory that run-tests is run from - * - */ - private function setWorkingDirectory() { - $this->settings['WorkingDirectory']= $this->setters['WorkingDirectory']->get(); - } + /** + * Sets the names of directories to be tested + * + */ + private function setTestDirectories() { + $this->settings['TestDirectories'] = $this->setters['TestDirectories']->get(); + } + /** + * Sets the names of files to be tested + * + * @param array $testFiles + */ + private function setTestFiles() { + $this->settings['TestFiles'] = $this->setters['TestFiles']->get(); + } - /** - * Sets the PHP executable being used to run teh tests - * - */ - private function setPhpExecutable() { - $this->settings['PhpExecutable']= $this->setters['PhpExecutable']->get(); - } - - - /** - * Sets the PHP GGI executable being used to run the tests - * - */ - private function setPhpCgiExecutable() { - $this->settings['PhpCgiExecutable']= $this->setters['PhpCgiExecutable']->get(); + /** + * Returns the value of a setting + * + * @param string $settingName + * @param mixed (may be array or string) + */ - } + public function getSetting($settingName) { + return $this->settings[$settingName]; + } - /** - * Sets the log format - * - */ - private function setLogFormat() { - $this->settings['LogFormat']= $this->setters['LogFormat']->get(); - } - + /** + * Returns the entire settings array + * + * @return array $settings + */ + public function getSettings() { + return $this->settings; + } - /** - * Sets the command line arguments for PHP - * - */ - private function setPhpCommandLineArguments() { - $this->settings['PhpCommandLineArguments']= $this->setters['PhpCommandLineArguments']->get(); - } + public function getEnvironmentVariable($name) { + return $this->environmentVariables->getVariable($name); + } + + public function getEnvironmentVariables() { + return $this->environmentVariables->getVariables(); + } + public function hasCommandLineOption($option) { + return $this->commandLine->hasOption($option); + } - /** - * Sets the names of directories to be tested - * - */ - private function setTestDirectories() { - $this->settings['TestDirectories'] = $this->setters['TestDirectories']->get(); - } - - - /** - * Sets the names of files to be tested - * - * @param array $testFiles - */ - private function setTestFiles() { - $this->settings['TestFiles'] = $this->setters['TestFiles']->get(); - } - - - /** - * Returns the value of a setting - * - * @param string $settingName - * @param mixed (may be array or string) - */ - - public function getSetting($settingName) { - return $this->settings[$settingName]; - } - - - /** - * Returns the entire settings array - * - * @return array $settings - */ - public function getSettings() { - return $this->settings; - } - - public function getEnvironmentVariable($name) { - return $this->environmentVariables->getVariable($name); - } - - public function getEnvironmentVariables() { - return $this->environmentVariables->getVariables(); - } - - public function hasCommandLineOption($option) { - return $this->commandLine->hasOption($option); - } - - public function getCommandLineOption($option) { - return $this->commandLine->getOption($option); - } - - - public function hasEnvironmentVariable($name) { - return $this->environmentVariables->hasVariable($name); - } - - /** - * required for testing? - * - * @param unknown_type $name - * @param unknown_type $value - * @return unknown - */ - public function setEnvironmentVariable($name, $value) { - $this->environmentVariables->setVariable($name, $value); - } - - public function getTestFilename() { - return $this->commandLine->getTestFilename(); - } + public function getCommandLineOption($option) { + return $this->commandLine->getOption($option); + } + + public function hasEnvironmentVariable($name) { + return $this->environmentVariables->hasVariable($name); + } + /** + * required for testing? + * + * @param unknown_type $name + * @param unknown_type $value + * @return unknown + */ + public function setEnvironmentVariable($name, $value) { + $this->environmentVariables->setVariable($name, $value); + } + + public function getTestFilename() { + return $this->commandLine->getTestFilename(); + } } - - ?> diff --git a/src/configuration/rtSetting.php b/src/configuration/rtSetting.php index a7c6e5e..42dc71c 100644 --- a/src/configuration/rtSetting.php +++ b/src/configuration/rtSetting.php @@ -4,30 +4,23 @@ * Classes that set things in the test configuration * */ - - -abstract class rtSetting { - - - public function __construct(rtRuntestsConfiguration $configuration) { - $this->init($configuration); - } - - - - /** - * Sets a variable from command line options or environmental variables - * - */ - abstract public function init(rtRuntestsConfiguration $configuration); - - - /** - * Applies the setting to the global environment - * - * @param rtGlobalEnvironment $env - */ - abstract public function get(); - +abstract class rtSetting +{ + public function __construct(rtRuntestsConfiguration $configuration) { + $this->init($configuration); + } + + /** + * Sets a variable from command line options or environmental variables + * + */ + abstract public function init(rtRuntestsConfiguration $configuration); + + /** + * Applies the setting to the global environment + * + * @param rtGlobalEnvironment $env + */ + abstract public function get(); } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtCurrentDirectorySetting.php b/src/configuration/settings/rtCurrentDirectorySetting.php index dee4195..ec3f92e 100644 --- a/src/configuration/settings/rtCurrentDirectorySetting.php +++ b/src/configuration/settings/rtCurrentDirectorySetting.php @@ -4,26 +4,26 @@ * Class to set the directory at the start of the run * */ -class rtCurrentDirectorySetting extends rtSetting { +class rtCurrentDirectorySetting extends rtSetting +{ + private $currentDirectory; - private $currentDirectory; - - /** - * Set the current directory - * - */ - public function init(rtRuntestsConfiguration $configuration) { - $this->currentDirectory = getcwd(); - } - - - /** - * Return current directory setting to the configuration - * - */ - public function get() { - return $this->currentDirectory; - } + /** + * Set the current directory + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + $this->currentDirectory = getcwd(); + } + /** + * Return current directory setting to the configuration + * + */ + public function get() + { + return $this->currentDirectory; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtLogFormatSetting.php b/src/configuration/settings/rtLogFormatSetting.php index 5010b2d..1069b2c 100644 --- a/src/configuration/settings/rtLogFormatSetting.php +++ b/src/configuration/settings/rtLogFormatSetting.php @@ -4,35 +4,31 @@ * Sets the format of the log file * */ -class rtLogFormatSetting extends rtSetting { - - private $logFormat; - - - /** - * Sets log format to that specifiled by TEST_PHP_LOG_FORMAT or LEOD - * - */ - public function init(rtRuntestsConfiguration $configuration) { - - if ($configuration->hasEnvironmentVariable('TEST_PHP_LOG_FORMAT')) { - $this->logFormat = strtoupper($configuration->getEnvironmentVariable('TEST_PHP_LOG_FORMAT')); - } else { - $this->logFormat = 'LEOD'; - +class rtLogFormatSetting extends rtSetting +{ + private $logFormat; + + /** + * Sets log format to that specifiled by TEST_PHP_LOG_FORMAT or LEOD + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if ($configuration->hasEnvironmentVariable('TEST_PHP_LOG_FORMAT')) { + $this->logFormat = strtoupper($configuration->getEnvironmentVariable('TEST_PHP_LOG_FORMAT')); + } else { + $this->logFormat = 'LEOD'; + } } - } - - - /** - * Apply log format setting to the configuration - * - * - */ - public function get() { - return $this->logFormat; - } + /** + * Apply log format setting to the configuration + * + * + */ + public function get() + { + return $this->logFormat; + } } - ?> diff --git a/src/configuration/settings/rtPhpCgiExecutableSetting.php b/src/configuration/settings/rtPhpCgiExecutableSetting.php index fb83062..728b95c 100644 --- a/src/configuration/settings/rtPhpCgiExecutableSetting.php +++ b/src/configuration/settings/rtPhpCgiExecutableSetting.php @@ -4,44 +4,43 @@ * Class for setting the PHP CGI executable * */ -class rtPhpCgiExecutableSetting extends rtSetting{ - - private $phpCgiExecutable; - const SAPI_CGI = "/sapi/cgi/php"; - - - /** - * Sets the PHP CGI executable. Note the dependency on having a working directory setting - * - */ - public function init(rtRuntestsConfiguration $configuration) { +class rtPhpCgiExecutableSetting extends rtSetting +{ + const SAPI_CGI = "/sapi/cgi/php"; + + private $phpCgiExecutable; - if(is_null($configuration->getSetting('workingDirectory'))) { - $workingDir = 'WORKING_DIR'; - } else { - $workingDir = $configuration->getSetting('workingDirectory'); + /** + * Sets the PHP CGI executable. Note the dependency on having a working directory setting + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if (is_null($configuration->getSetting('workingDirectory'))) { + $workingDir = 'WORKING_DIR'; + } else { + $workingDir = $configuration->getSetting('workingDirectory'); + } + + if ($configuration->hasEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE')) { + if($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') { + $this->phpCgiExecutable = $workingDir . self::SAPI_CGI; + } else { + $this->phpCgiExecutable = $configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'); + } + } else { + $this->phpCgiExecutable = null; + } } - if ($configuration->hasEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE')) { - if($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') { - $this->phpCgiExecutable = $workingDir.self::SAPI_CGI; - } else { - $this->phpCgiExecutable = $configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'); - } - } else { - $this->phpCgiExecutable=null; - } - } - - - /** - * Supply the setting to the configuration on request - * - */ - public function get() { - return $this->phpCgiExecutable; - } - + + /** + * Supply the setting to the configuration on request + * + */ + public function get() + { + return $this->phpCgiExecutable; + } } - -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtPhpCommandLineArgSetting.php b/src/configuration/settings/rtPhpCommandLineArgSetting.php index dc14efd..d502d4d 100644 --- a/src/configuration/settings/rtPhpCommandLineArgSetting.php +++ b/src/configuration/settings/rtPhpCommandLineArgSetting.php @@ -1,38 +1,35 @@ <?php + /** * Sets the arguments to teh PHP command line, initially as ini overrides * converted to -d flags * */ -class rtPhpCommandLineArgSetting extends rtSetting { - - private $phpCommandLineArguments; - - - - /** - * Sets the command line arguments for - * - */ - public function init(rtRuntestsConfiguration $configuration) { - $iniArguments = new rtIniAsCommandLineArgs(); - $iniArguments->setBase(); - $this->phpCommandLineArguments = $iniArguments->getBasePhpDArgs(); +class rtPhpCommandLineArgSetting extends rtSetting +{ + private $phpCommandLineArguments; - if($configuration->hasCommandLineOption('n')) { - $this->phpCommandLineArguments = '-n ' . $this->phpCommandLineArguments; + /** + * Sets the command line arguments for + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + $iniArguments = new rtIniAsCommandLineArgs(); + $iniArguments->setBase(); + $this->phpCommandLineArguments = $iniArguments->getBasePhpDArgs(); + + if ($configuration->hasCommandLineOption('n')) { + $this->phpCommandLineArguments = '-n ' . $this->phpCommandLineArguments; + } + } + + /** + * Supply commandline arguments setting to the run configuration + * + */ + public function get() { + return $this->phpCommandLineArguments; } - - } - - - /** - * Supply commandline arguments setting to the run configuration - * - */ - public function get() { - return $this->phpCommandLineArguments; - } - } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtPhpExecutableSetting.php b/src/configuration/settings/rtPhpExecutableSetting.php index 0f51318..b24bc30 100644 --- a/src/configuration/settings/rtPhpExecutableSetting.php +++ b/src/configuration/settings/rtPhpExecutableSetting.php @@ -4,47 +4,46 @@ * Class to set the PHP executable to be tested * */ -class rtPhpExecutableSetting extends rtSetting{ - - private $phpExecutable; - - const SAPI_CLI = "/sapi/cli/php"; - - - /** - * Sets the PHP executable, note the dependency on working directory - * - */ - public function init(rtRuntestsConfiguration $configuration) { - - if(is_null($configuration->getSetting('workingDirectory'))) { - $workingDir = 'WORKING_DIR'; - } else { - $workingDir = $configuration->getSetting('workingDirectory'); - } +class rtPhpExecutableSetting extends rtSetting +{ + const SAPI_CLI = "/sapi/cli/php"; + + private $phpExecutable; - if ($configuration->hasEnvironmentVariable('TEST_PHP_EXECUTABLE')) { - if($configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE') == 'auto') { - $this->phpExecutable = $workingDir.self::SAPI_CLI; + /** + * Sets the PHP executable, note the dependency on working directory + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if (is_null($configuration->getSetting('workingDirectory'))) { + $workingDir = 'WORKING_DIR'; + } else { + $workingDir = $configuration->getSetting('workingDirectory'); + } + + if ($configuration->hasEnvironmentVariable('TEST_PHP_EXECUTABLE')) { - } else { - $this->phpExecutable = $configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE'); - } - } - if ($configuration->hasCommandLineOption('p')) { - $this->phpExecutable = $configuration->getCommandLineOption('p'); + if($configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE') == 'auto') { + $this->phpExecutable = $workingDir.self::SAPI_CLI; + } else { + $this->phpExecutable = $configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE'); + } + } + + if ($configuration->hasCommandLineOption('p')) { + $this->phpExecutable = $configuration->getCommandLineOption('p'); + } } - } - - - /** - * Supply the PHP executable setting to the configuration - * - */ - public function get() { - return $this->phpExecutable; - } - + + /** + * Supply the PHP executable setting to the configuration + * + */ + public function get() + { + return $this->phpExecutable; + } } ?> diff --git a/src/configuration/settings/rtTestDirectorySetting.php b/src/configuration/settings/rtTestDirectorySetting.php index 1d9bf56..6f572db 100644 --- a/src/configuration/settings/rtTestDirectorySetting.php +++ b/src/configuration/settings/rtTestDirectorySetting.php @@ -5,43 +5,44 @@ * to be tested and can be provided on teh command line or by TEST_PHP_USER * */ -class rtTestDirectorySetting extends rtSetting { - - private $testDir = null; +class rtTestDirectorySetting extends rtSetting +{ + private $testDir = null; + + /** + * Check each option - if it's a directory add it to the list. + * If not leave it. + * + * @param rtCommandLine $commandLine + * @param rtEnvironmentVariables $environmentVariables + */ + public function init(rtRuntestsConfiguration $configuration) + { + $fileArray = $configuration->getTestFilename(); - - /** - * Check each option - if it's a directory add it to the list. - * If not leave it. - * - * @param rtCommandLine $commandLine - * @param rtEnvironmentVariables $environmentVariables - */ - public function init(rtRuntestsConfiguration $configuration) { - $fileArray = $configuration->getTestFilename(); - foreach($fileArray as $file) { - if( is_dir($file)) { - $this->testDir[]= $file; - } - } - if($configuration->hasEnvironmentVariable('TEST_PHP_USER')) { - $fileArray = trim($configuration->getEnvironmentVariable('TEST_PHP_USER')); - foreach($fileArray as $file) { - if( is_dir($file)) { - $this->testDir[]= $file; + foreach($fileArray as $file) { + if( is_dir($file)) { + $this->testDir[]= $file; + } + } + + if($configuration->hasEnvironmentVariable('TEST_PHP_USER')) { + $fileArray = trim($configuration->getEnvironmentVariable('TEST_PHP_USER')); + foreach($fileArray as $file) { + if( is_dir($file)) { + $this->testDir[]= $file; + } + } } - } } - } - - - /** - * Set the test directory/directories list in the configuration - * - */ - public function get() { - return $this->testDir; - } - + + /** + * Set the test directory/directories list in the configuration + * + */ + public function get() + { + return $this->testDir; + } } -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtTestFileSetting.php b/src/configuration/settings/rtTestFileSetting.php index d45a1aa..1146663 100644 --- a/src/configuration/settings/rtTestFileSetting.php +++ b/src/configuration/settings/rtTestFileSetting.php @@ -5,52 +5,51 @@ * from the command line or as lists in files using the command line -r or -l options * */ -class rtTestFileSetting extends rtSetting { - - private $testFiles; +class rtTestFileSetting extends rtSetting +{ + private $testFiles; - /** - * Check each filename - if it's not a directory and the name ends .phpt - * add it to the list. Also read the -l and -r options and do the same checking with those - * - * @param rtCommandLine $commandLine - * - */ - public function init(rtRuntestsConfiguration $configuration) { - $fileArray = $configuration->getTestFilename(); - foreach($fileArray as $fn) { - if( !is_dir($fn) && substr( $fn, -5) == ".phpt") { - $this->testFiles[]= $fn; - } - } + /** + * Check each filename - if it's not a directory and the name ends .phpt + * add it to the list. Also read the -l and -r options and do the same checking with those + * + * @param rtCommandLine $commandLine + * + */ + public function init(rtRuntestsConfiguration $configuration) { + $fileArray = $configuration->getTestFilename(); - if($configuration->hasCommandLineOption('l')) { - $fileArray = file($configuration->getCommandLineOption('l')); - foreach($fileArray as $file) { - if(substr( trim($file), -5) == ".phpt") { - $this->testFiles[]= trim($file); + foreach($fileArray as $fn) { + if( !is_dir($fn) && substr($fn, -5) == ".phpt") { + $this->testFiles[] = $fn; + } + } + + if($configuration->hasCommandLineOption('l')) { + $fileArray = file($configuration->getCommandLineOption('l')); + foreach($fileArray as $file) { + if(substr(trim($file), -5) == ".phpt") { + $this->testFiles[] = trim($file); + } + } } - } - } - if($configuration->hasCommandLineOption('r')) { - $fileArray = file($configuration->getCommandLineOption('r')); - foreach($fileArray as $file) { - if(substr( trim($file), -5) == ".phpt") { - $this->testFiles[]= trim($file); + if($configuration->hasCommandLineOption('r')) { + $fileArray = file($configuration->getCommandLineOption('r')); + foreach($fileArray as $file) { + if(substr(trim($file), -5) == ".phpt") { + $this->testFiles[] = trim($file); + } + } } - } } - } - - /** - * Reurns a list of test files - * - */ - public function get() { - return $this->testFiles; - } + /** + * Reurns a list of test files + * + */ + public function get() { + return $this->testFiles; + } } - -?> \ No newline at end of file +?> diff --git a/src/configuration/settings/rtWorkingDirectorySetting.php b/src/configuration/settings/rtWorkingDirectorySetting.php index 78f4912..2c3408c 100644 --- a/src/configuration/settings/rtWorkingDirectorySetting.php +++ b/src/configuration/settings/rtWorkingDirectorySetting.php @@ -5,33 +5,30 @@ * that run-tests.php was started from) * */ -class rtWorkingDirectorySetting extends rtSetting { - - private $workingDirectory; - - - - /** - * Sets the working directory - * - */ - public function init(rtRuntestsConfiguration $configuration) { - - if($configuration->hasEnvironmentVariable('TEST_PHP_SRCDIR')) { - $this->workingDirectory = $configuration->getEnvironmentVariable('TEST_PHP_SRCDIR'); - } else { - $this->workingDirectory = getcwd(); +class rtWorkingDirectorySetting extends rtSetting +{ + private $workingDirectory; + + /** + * Sets the working directory + * + */ + public function init(rtRuntestsConfiguration $configuration) + { + if($configuration->hasEnvironmentVariable('TEST_PHP_SRCDIR')) { + $this->workingDirectory = $configuration->getEnvironmentVariable('TEST_PHP_SRCDIR'); + } else { + $this->workingDirectory = getcwd(); + } } - } - - - /** - * Supply working directory to the configuration - * - */ - public function get() { - return $this->workingDirectory; - } - + + /** + * Supply working directory to the configuration + * + */ + public function get() + { + return $this->workingDirectory; + } } ?> diff --git a/src/rtDirectoryList.php b/src/rtDirectoryList.php index fb5352d..cd8fe50 100644 --- a/src/rtDirectoryList.php +++ b/src/rtDirectoryList.php @@ -7,21 +7,21 @@ */ class rtDirectoryList { - /** - * Finds a list of subdirectories under the top level ditectory and returns the full path names in an array - * - * @param string $topDirectory - * @return array - */ - public function getSubDirectoryPaths($topDirectory) - { - $result = array($topDirectory); - - foreach (new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($topDirectory)), 1) as $dir) { - $result[] = $dir->getPathName(); - } - - return $result; - } + /** + * Finds a list of subdirectories under the top level ditectory and returns the full path names in an array + * + * @param string $topDirectory + * @return array + */ + public function getSubDirectoryPaths($topDirectory) + { + $result = array($topDirectory); + + foreach (new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($topDirectory)), 1) as $dir) { + $result[] = $dir->getPathName(); + } + + return $result; + } } ?>