com phpruntests: Fixing Georg's problem?: src/configurati on/settings/rtPhpCgiExecutableSetting.php tests/configurati
on/settings/rtPhpCgiExecutableSettingTest.php

From: Date: Fri, 15 May 2009 06:48:07 +0000
Subject: com phpruntests: Fixing Georg's problem?: src/configurati on/settings/rtPhpCgiExecutableSetting.php tests/configurati
on/settings/rtPhpCgiExecutableSettingTest.php
Groups: php.qa 
Request: Send a blank email to php-qa+get-66461@lists.php.net to get a copy of this message
Commit: eb909c4526662caec234ab466dd8f0af90783f0b Author: Zoe Slattery <zoe@php.net> Fri, 15 May 2009 06:48:07 +0000 Parents: 09e67628ee6e11c5ff8039dd1b261313276cc2f0 Branches: master Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=eb909c4526662caec234ab466dd8f0af90783f0b Log: Fixing Georg's problem? Changed paths: M src/configuration/settings/rtPhpCgiExecutableSetting.php M tests/configuration/settings/rtPhpCgiExecutableSettingTest.php Diff: diff --git a/src/configuration/settings/rtPhpCgiExecutableSetting.php b/src/configuration/settings/rtPhpCgiExecutableSetting.php index 9be4050..7b17d1d 100644 --- a/src/configuration/settings/rtPhpCgiExecutableSetting..php +++ b/src/configuration/settings/rtPhpCgiExecutableSetting.php @@ -9,9 +9,9 @@ class rtPhpCgiExecutableSetting extends rtSetting const SAPI_CGI = "/sapi/cgi/php-cgi"; private $phpCgiExecutable; - + private $configuration; - + /** * Sets the PHP CGI executable. Note the dependency on having a working directory setting * @@ -19,28 +19,30 @@ class rtPhpCgiExecutableSetting extends rtSetting public function init(rtRuntestsConfiguration $configuration) { $this->configuration = $configuration; - + if ($configuration->hasEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE')) { - if ($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') { + if($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') != null) { + if ($configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE') == 'auto') { - $rtWorkingDirectorySetting = new rtWorkingDirectorySetting($configuration); - $this->phpCgiExecutable = $rtWorkingDirectorySetting->get() . self::SAPI_CGI; - } else { - $this->phpCgiExecutable = $configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'); + $rtWorkingDirectorySetting = new rtWorkingDirectorySetting($configuration); + $this->phpCgiExecutable = $rtWorkingDirectorySetting->get() . self::SAPI_CGI; + } else { + $this->phpCgiExecutable = $configuration->getEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE'); + } } - } + } } - + /** * @todo spriebsch: does this method need to be public, is it only called from get()? - * @todo zoe:This method only works if we are running from a PHP source tree, do we need to + * @todo zoe:This method only works if we are running from a PHP source tree, do we need to * cope with /usr/local/bin/php for example? */ public function guessFromPhpCli($phpCli) { - if(substr(dirname($phpCli),-3) == 'cli') { + if(substr(dirname($phpCli),-3) == 'cli') { $pathLength = strlen(dirname($phpCli)) - 3; - $sapiDir = substr(dirname($phpCli), 0, $pathLength); + $sapiDir = substr(dirname($phpCli), 0, $pathLength); $this->phpCgiExecutable = $sapiDir."cgi/php-cgi"; } } @@ -51,7 +53,7 @@ class rtPhpCgiExecutableSetting extends rtSetting * * @return string */ - public function get() + public function get() { if (is_null($this->phpCgiExecutable)) { @@ -59,8 +61,8 @@ class rtPhpCgiExecutableSetting extends rtSetting $rtPhpExecutableSetting = new rtPhpExecutableSetting($this->configuration); $this->guessFromPhpCli($rtPhpExecutableSetting->get()); } - + return $this->phpCgiExecutable; - } + } } ?> diff --git a/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php b/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php index 2c1ae79..f625cb4 100644 --- a/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php +++ b/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php @@ -23,13 +23,15 @@ class rtPhpCgiExecutableSettingTest extends PHPUnit_Framework_TestCase public function testSetPhpCgiExecutableNotSet() { $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', 'test.phpt')); + $configuration->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', ''); $setting = new rtPhpCgiExecutableSetting($configuration); $this->assertEquals(null, $setting->get()); } public function testSetFromCliExecutableName() { - $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/a/sapi/cli/a-php-exe', 'test.phpt')); + $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', '-p', '/a/sapi/cli/php', 'test.phpt')); + $configuration->setEnvironmentVariable('TEST_PHP_CGI_EXECUTABLE', null); $setting = new rtPhpCgiExecutableSetting($configuration); $this->assertEquals('/a/sapi/cgi/php-cgi', $setting->get());

« previous php.qa (#66461) next »