spriebsch Tue May 12 09:15:19 2009 UTC
Modified files:
/phpruntests/tests/configuration/settings
rtCurrentDirectorySettingTest.php
rtLogFormatSettingTest.php
rtPhpCgiExecutableSettingTest.php
rtPhpCommandLineArgSettingTest.php
rtPhpExecutableSettingTest.php
rtTestDirectorySettingTest.php
rtWorkingDirectorySettingTest.php
/phpruntests/src/configuration rtRuntestsConfiguration.php
rtSetting.php
/phpruntests/src/configuration/settings
rtPhpCgiExecutableSetting.php
rtPhpExecutableSetting.php
Log:
Refactored rtRuntestsConfiguration and adjusted the unit tests.
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtCurrentDirectorySettingTest.php?r1=1.3&r2=1.4&diff_format=u
Index:
phpruntests/tests/configuration/settings/rtCurrentDirectorySettingTest.php
diff -u
phpruntests/tests/configuration/settings/rtCurrentDirectorySettingTest.php:1.3
phpruntests/tests/configuration/settings/rtCurrentDirectorySettingTest.php:1.4
---
phpruntests/tests/configuration/settings/rtCurrentDirectorySettingTest.php:1.3
Sun Apr 26 06:54:34 2009
+++ phpruntests/tests/configuration/settings/rtCurrentDirectorySettingTest.php
Tue May 12 09:15:18 2009
@@ -8,9 +8,9 @@
public function testSetting()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
'test.phpt'));
- $dirsetting = new rtCurrentDirectorySetting($configuration);
+ $setting = new rtCurrentDirectorySetting($configuration);
- $this->assertEquals(realpath(getcwd()), $dirsetting->get());
+ $this->assertEquals(realpath(getcwd()), $setting->get());
}
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtLogFormatSettingTest.php?r1=1.2&r2=1.3&diff_format=u
Index: phpruntests/tests/configuration/settings/rtLogFormatSettingTest.php
diff -u phpruntests/tests/configuration/settings/rtLogFormatSettingTest.php:1.2
phpruntests/tests/configuration/settings/rtLogFormatSettingTest.php:1.3
--- phpruntests/tests/configuration/settings/rtLogFormatSettingTest.php:1.2
Mon Apr 20 20:50:39 2009
+++ phpruntests/tests/configuration/settings/rtLogFormatSettingTest.php Tue May
12 09:15:18 2009
@@ -9,16 +9,16 @@
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
'test.phpt'));
$configuration->setEnvironmentVariable('TEST_PHP_LOG_FORMAT',
'some-log-format');
- $logsetting = new rtLogFormatSetting($configuration);
+ $setting = new rtLogFormatSetting($configuration);
- $this->assertEquals('SOME-LOG-FORMAT', $logsetting->get());
+ $this->assertEquals('SOME-LOG-FORMAT', $setting->get());
}
public function testSetLEOD() {
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
'test.phpt'));
- $logsetting = new rtLogFormatSetting($configuration);
+ $setting = new rtLogFormatSetting($configuration);
- $this->assertEquals('LEOD', $logsetting->get());
+ $this->assertEquals('LEOD', $setting->get());
}
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php?r1=1.4&r2=1.5&diff_format=u
Index:
phpruntests/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php
diff -u
phpruntests/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php:1.4
phpruntests/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php:1.5
---
phpruntests/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php:1.4
Sun Apr 26 06:54:34 2009
+++ phpruntests/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php
Tue May 12 09:15:18 2009
@@ -8,27 +8,31 @@
public function testSetPhpCgiExecutableEV() {
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', 'test.phpt'));
$configuration->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE',
'a-php-executable');
- $cgisetting = new rtPhpCgiExecutableSetting($configuration);
- $this->assertEquals('a-php-executable', $cgisetting->get());
+ $setting = new rtPhpCgiExecutableSetting($configuration);
+
+ $this->assertEquals('a-php-executable', $setting->get());
}
public function testSetPhpCgiExecutableEVAuto() {
- $configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php','-p', 'a-php-exe',
'test.phpt'));
+ $configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
'test.phpt'));
$configuration->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE',
'auto');
- $configuration->configure();
- $this->assertEquals(realpath(getcwd()).'/sapi/cgi/php',
$configuration->getSetting('PhpCgiExecutable'));
+ $setting = new rtPhpCgiExecutableSetting($configuration);
+
+ $this->assertEquals(realpath(getcwd()).'/sapi/cgi/php-cgi',
$setting->get('PhpCgiExecutable'));
}
public function testSetPhpCgiExecutableNotSet() {
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', 'test.phpt'));
- $cgisetting = new rtPhpCgiExecutableSetting($configuration);
- $this->assertEquals(null, $cgisetting->get());
+ $setting = new rtPhpCgiExecutableSetting($configuration);
+
+ $this->assertEquals(null, $setting->get());
}
public function testSetFromCliExecutableName() {
- $config = rtRuntestsConfiguration::getInstance(array('run-tests.php',
'-p', '/a/sapi/cli/a-php-exe', 'test.phpt'));
- $config->configure();
- $this->assertEquals('/a/sapi/cgi/php',
$config->getSetting('PhpCgiExecutable'));
+ $configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p',
'/a/sapi/cli/a-php-exe', 'test.phpt'));
+ $setting = new rtPhpCgiExecutableSetting($configuration);
+
+ $this->assertEquals('/a/sapi/cgi/php-cgi', $setting->get());
}
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtPhpCommandLineArgSettingTest.php?r1=1.2&r2=1.3&diff_format=u
Index:
phpruntests/tests/configuration/settings/rtPhpCommandLineArgSettingTest.php
diff -u
phpruntests/tests/configuration/settings/rtPhpCommandLineArgSettingTest.php:1.2
phpruntests/tests/configuration/settings/rtPhpCommandLineArgSettingTest.php:1.3
---
phpruntests/tests/configuration/settings/rtPhpCommandLineArgSettingTest.php:1.2
Mon Apr 20 20:50:39 2009
+++ phpruntests/tests/configuration/settings/rtPhpCommandLineArgSettingTest.php
Tue May 12 09:15:18 2009
@@ -9,8 +9,8 @@
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p',
'a-php-executable'));
- $clArgsetting = new rtPhpCommandLineArgSetting($configuration);
- $last49 = addslashes(substr($clArgsetting->get(), -49));
+ $setting = new rtPhpCommandLineArgSetting($configuration);
+ $last49 = addslashes(substr($setting->get(), -49));
$this->assertEquals('-d
\"unicode.from_error_mode=U_INVALID_SUBSTITUTE\"', $last49);
}
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtPhpExecutableSettingTest.php?r1=1.4&r2=1.5&diff_format=u
Index: phpruntests/tests/configuration/settings/rtPhpExecutableSettingTest.php
diff -u
phpruntests/tests/configuration/settings/rtPhpExecutableSettingTest.php:1.4
phpruntests/tests/configuration/settings/rtPhpExecutableSettingTest.php:1.5
--- phpruntests/tests/configuration/settings/rtPhpExecutableSettingTest.php:1.4
Sun Apr 26 06:54:34 2009
+++ phpruntests/tests/configuration/settings/rtPhpExecutableSettingTest.php
Tue May 12 09:15:18 2009
@@ -5,41 +5,40 @@
class rtPhpExecutableSettingTest extends PHPUnit_Framework_TestCase
{
- public function testSetPhpExecutable()
+ public function testSetPhpExecutableFromCommandLineOption()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p',
'a-php-executable'));
+ $setting = new rtPhpExecutableSetting($configuration);
- $clisetting = new rtPhpExecutableSetting($configuration);
-
- $this->assertEquals('a-php-executable', $clisetting->get());
+ $this->assertEquals('a-php-executable', $setting->get());
}
- public function testSetPhpExecutableEV()
+ public function testSetPhpExecutableFromEnvironmentVariable()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php'));
$configuration->setEnvironmentVariable('TEST_PHP_EXECUTABLE',
'a-php-executable');
+ $setting = new rtPhpExecutableSetting($configuration);
- $clisetting = new rtPhpExecutableSetting($configuration);
-
- $this->assertEquals('a-php-executable', $clisetting->get());
+ $this->assertEquals('a-php-executable', $setting->get());
}
- public function testSetPhpExecutableEvAuto()
+ public function testSetPhpExecutableAutomaticallyFromEnvironmentVariable()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', 'test.phpt'));
$configuration->setEnvironmentVariable('TEST_PHP_EXECUTABLE', 'auto');
$configuration->setEnvironmentVariable('TEST_PHP_SRCDIR',
'/some/directory');
- $configuration->configure();
- $this->assertEquals('/some/directory/sapi/cli/php',
$configuration->getSetting('PhpExecutable'));
+ $setting = new rtPhpExecutableSetting($configuration);
+
+ $this->assertEquals('/some/directory/sapi/cli/php',
$setting->get('PhpExecutable'));
}
- public function testSetPhpExecutableCwdAuto()
+ public function
testSetPhpExecutableAutomaticallyFromEnvironmentVariableAndWorkingDirectory()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', 'test.phpt'));
$configuration->setEnvironmentVariable('TEST_PHP_EXECUTABLE', 'auto');
- $configuration->configure();
+ $setting = new rtPhpExecutableSetting($configuration);
- $this->assertEquals(realpath(getcwd()).'/sapi/cli/php',
$configuration->getSetting('PhpExecutable'));
+ $this->assertEquals(realpath(getcwd()).'/sapi/cli/php',
$setting->get('PhpExecutable'));
}
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtTestDirectorySettingTest.php?r1=1.2&r2=1.3&diff_format=u
Index: phpruntests/tests/configuration/settings/rtTestDirectorySettingTest.php
diff -u
phpruntests/tests/configuration/settings/rtTestDirectorySettingTest.php:1.2
phpruntests/tests/configuration/settings/rtTestDirectorySettingTest.php:1.3
--- phpruntests/tests/configuration/settings/rtTestDirectorySettingTest.php:1.2
Mon Apr 20 20:50:39 2009
+++ phpruntests/tests/configuration/settings/rtTestDirectorySettingTest.php
Tue May 12 09:15:18 2009
@@ -17,12 +17,9 @@
public function testSet()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
$this->d1, $this->d2));
- $testdirsetting = new rtTestDirectorySetting($configuration);
+ $setting = new rtTestDirectorySetting($configuration);
- $dirlist = $testdirsetting->get();
-
- $this->assertEquals($dirlist[0], $this->d1);
- $this->assertEquals($dirlist[1], $this->d2);
+ $this->assertEquals($setting->get(), array($this->d1, $this->d2));
}
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/tests/configuration/settings/rtWorkingDirectorySettingTest.php?r1=1.2&r2=1.3&diff_format=u
Index:
phpruntests/tests/configuration/settings/rtWorkingDirectorySettingTest.php
diff -u
phpruntests/tests/configuration/settings/rtWorkingDirectorySettingTest.php:1.2
phpruntests/tests/configuration/settings/rtWorkingDirectorySettingTest.php:1.3
---
phpruntests/tests/configuration/settings/rtWorkingDirectorySettingTest.php:1.2
Mon Apr 20 20:50:39 2009
+++ phpruntests/tests/configuration/settings/rtWorkingDirectorySettingTest.php
Tue May 12 09:15:18 2009
@@ -8,18 +8,18 @@
public function testSet()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
'test.phpt'));
- $dirsetting = new rtWorkingDirectorySetting($configuration);
+ $setting = new rtWorkingDirectorySetting($configuration);
- $this->assertEquals(getcwd(), $dirsetting->get());
+ $this->assertEquals(getcwd(), $setting->get());
}
public function testSetFromEnv()
{
$configuration =
rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', 'a-php-exe',
'test.phpt'));
$configuration->setEnvironmentVariable('TEST_PHP_SRCDIR',
'the-source-dir');
- $dirsetting = new rtWorkingDirectorySetting($configuration);
+ $setting = new rtWorkingDirectorySetting($configuration);
- $this->assertEquals('the-source-dir', $dirsetting->get());
+ $this->assertEquals('the-source-dir', $setting->get());
}
}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/src/configuration/rtRuntestsConfiguration.php?r1=1.6&r2=1.7&diff_format=u
Index: phpruntests/src/configuration/rtRuntestsConfiguration.php
diff -u phpruntests/src/configuration/rtRuntestsConfiguration.php:1.6
phpruntests/src/configuration/rtRuntestsConfiguration.php:1.7
--- phpruntests/src/configuration/rtRuntestsConfiguration.php:1.6 Wed May
6 20:45:42 2009
+++ phpruntests/src/configuration/rtRuntestsConfiguration.php Tue May 12
09:15:19 2009
@@ -31,19 +31,18 @@
protected $commandLineArgs;
private $settings;
- private $setters;
private $environmentVariables;
private $commandLine;
private $settingNames = array (
- 'CurrentDirectory' => 'rtCurrentDirectorySetting',
- 'WorkingDirectory' => 'rtWorkingDirectorySetting',
- 'LogFormat' => 'rtLogFormatSetting',
- 'PhpExecutable' => 'rtPhpExecutableSetting',
- 'PhpCgiExecutable' => 'rtPhpCgiExecutableSetting',
- 'TestFiles' => 'rtTestFileSetting',
- 'TestDirectories' => 'rtTestDirectorySetting',
- 'PhpCommandLineArguments' => 'rtPhpCommandLineArgSetting',
+ 'rtCurrentDirectorySetting',
+ 'rtWorkingDirectorySetting',
+ 'rtLogFormatSetting',
+ 'rtPhpExecutableSetting',
+ 'rtPhpCgiExecutableSetting',
+ 'rtTestFileSetting',
+ 'rtTestDirectorySetting',
+ 'rtPhpCommandLineArgSetting',
);
protected function init()
@@ -57,7 +56,9 @@
$this->environmentVariables->getUserSuppliedVariables();
}
-
+ /**
+ * @todo spriebsch: is configure() the right name for this method, it
checks preconditions?
+ */
public function configure()
{
//extend test command line using TEST_PHP_ARGS
@@ -65,10 +66,9 @@
$options->parseAdditionalOptions($this->commandLine,
$this->environmentVariables);
//set configuration
- foreach ($this->settingNames as $name => $setting) {
- $this->setters[$name] = new $setting($this);
- $methodName = 'set' . $name;
- $this->$methodName();
+ foreach ($this->settingNames as $className) {
+ $object = new $className($this);
+ $this->settings[$className] = $object->get();
}
//check configuration preconditions
@@ -76,10 +76,7 @@
// $preConditionList->check($this->commandLine,
$this->environmentVariables);
- $preConditionList->check($this);
-
-
-
+ $preConditionList->check($this);
}
/**
@@ -97,85 +94,6 @@
}
/**
- * 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();
- }
-
- /**
- * 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()
- {
- //If the CGI executable hasn't been set using an environmental
variable or 'auto', try and derive it from
- //the name of the cli executable.
- //TODO This is *ix specific, need a WIN specific class
PhpCgiExecutable setting class
- if($this->setters['PhpCgiExecutable']->get() == null) {
-
$this->setters['PhpCgiExecutable']->setFromPhpCli($this->settings['PhpExecutable']);
- }
- $this->settings['PhpCgiExecutable']=
$this->setters['PhpCgiExecutable']->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 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
http://cvs.php.net/viewvc.cgi/phpruntests/src/configuration/rtSetting.php?r1=1.3&r2=1.4&diff_format=u
Index: phpruntests/src/configuration/rtSetting.php
diff -u phpruntests/src/configuration/rtSetting.php:1.3
phpruntests/src/configuration/rtSetting.php:1.4
--- phpruntests/src/configuration/rtSetting.php:1.3 Fri Apr 24 08:41:25 2009
+++ phpruntests/src/configuration/rtSetting.php Tue May 12 09:15:19 2009
@@ -1,7 +1,11 @@
<?php
/**
- * Classes that set things in the test configuration
+ * Classes that set things in the test configuration.
+ * Settings may instantiate other settings to retrieve values they need.
+ * This leads to some settings being instantiated multiple times, and
+ * being redundantly calculated, but makes settings independent from the order
+ * in which they are processed in rtRuntestsConfiguration.
*
*/
abstract class rtSetting
http://cvs.php.net/viewvc.cgi/phpruntests/src/configuration/settings/rtPhpCgiExecutableSetting.php?r1=1.6&r2=1.7&diff_format=u
Index: phpruntests/src/configuration/settings/rtPhpCgiExecutableSetting.php
diff -u
phpruntests/src/configuration/settings/rtPhpCgiExecutableSetting.php:1.6
phpruntests/src/configuration/settings/rtPhpCgiExecutableSetting.php:1.7
--- phpruntests/src/configuration/settings/rtPhpCgiExecutableSetting.php:1.6
Mon May 4 17:19:20 2009
+++ phpruntests/src/configuration/settings/rtPhpCgiExecutableSetting.php
Tue May 12 09:15:19 2009
@@ -10,29 +10,31 @@
private $phpCgiExecutable;
+ private $configuration;
+
/**
* Sets the PHP CGI executable. Note the dependency on having a working
directory setting
*
*/
public function init(rtRuntestsConfiguration $configuration)
{
-
+ $this->configuration = $configuration;
if ($configuration->hasEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'))
{
if
($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') {
- $this->phpCgiExecutable =
$configuration->getSetting('WorkingDirectory') . self::SAPI_CGI;
+
+ $rtWorkingDirectorySetting = new
rtWorkingDirectorySetting($configuration);
+ $this->phpCgiExecutable = $rtWorkingDirectorySetting->get() .
self::SAPI_CGI;
} else {
$this->phpCgiExecutable =
$configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE');
}
- } else {
- $this->phpCgiExecutable = null;
}
}
/**
- *
+ * @todo spriebsch: does this method need to be public, is it only called
from get()?
*/
- public function setFromPhpCli($phpCli)
+ public function guessFromPhpCli($phpCli)
{
if(substr(dirname($phpCli),-3) == 'cli') {
$pathLength = strlen(dirname($phpCli)) - 3;
@@ -40,15 +42,23 @@
$this->phpCgiExecutable = $sapiDir."cgi/php-cgi";
}
}
-
-
+
/**
- * Supply the setting to the configuration on request
+ * Returns path to PHP CGI executable.
+ * If not set, we guess based on the path to the PHP CLI executable.
*
+ * @return string
*/
public function get()
{
+ if (is_null($this->phpCgiExecutable)) {
+
+ // We ask rtPhpExecutableSetting for the path to the PHP
executable.
+ $rtPhpExecutableSetting = new
rtPhpExecutableSetting($this->configuration);
+ $this->guessFromPhpCli($rtPhpExecutableSetting->get());
+ }
+
return $this->phpCgiExecutable;
}
-}
+}
?>
http://cvs.php.net/viewvc.cgi/phpruntests/src/configuration/settings/rtPhpExecutableSetting.php?r1=1.4&r2=1.5&diff_format=u
Index: phpruntests/src/configuration/settings/rtPhpExecutableSetting.php
diff -u phpruntests/src/configuration/settings/rtPhpExecutableSetting.php:1.4
phpruntests/src/configuration/settings/rtPhpExecutableSetting.php:1.5
--- phpruntests/src/configuration/settings/rtPhpExecutableSetting.php:1.4
Sun Apr 26 06:54:12 2009
+++ phpruntests/src/configuration/settings/rtPhpExecutableSetting.php Tue May
12 09:15:19 2009
@@ -16,11 +16,12 @@
*/
public function init(rtRuntestsConfiguration $configuration)
{
-
if ($configuration->hasEnvironmentVariable('TEST_PHP_EXECUTABLE')) {
- if ($configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE')
== 'auto') {
- $this->phpExecutable =
$configuration->getSetting('WorkingDirectory').self::SAPI_CLI;
+ if ($configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE')
== 'auto') {
+
+ $rtWorkingDirectorySetting = new
rtWorkingDirectorySetting($configuration);
+ $this->phpExecutable = $rtWorkingDirectorySetting->get() .
self::SAPI_CLI;
} else {
$this->phpExecutable =
$configuration->getEnvironmentVariable('TEST_PHP_EXECUTABLE');
}
@@ -40,5 +41,4 @@
return $this->phpExecutable;
}
}
-
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php