com phpruntests: Adding a way of deriving the cgi executable from the cli. Matches current impl but will need win specific test:
src/configuration/rtRuntestsConfiguration.php src/configuration/settings/rtPhpCgiExecutableSetting.php
tests/configuration/settings/rtPhpCgiExecutableSettingTest.php

From: Date: Sat, 25 Apr 2009 17:18:37 +0000
Subject: com phpruntests: Adding a way of deriving the cgi executable from the cli. Matches current impl but will need win specific test:
src/configuration/rtRuntestsConfiguration.php src/configuration/settings/rtPhpCgiExecutableSetting.php
tests/configuration/settings/rtPhpCgiExecutableSettingTest.php
Groups: php.qa 
Request: Send a blank email to php-qa+get-66523@lists.php.net to get a copy of this message
Commit: 5aec3aa416780d112dfe508ce552fd9a7ed2c6d8 Author: Zoe Slattery <zoe@php.net> Sat, 25 Apr 2009 17:18:37 +0000 Parents: c881d818c271ffa8fe0ac580d8a8af5ee83027ce Branches: master Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=5aec3aa416780d112dfe508ce552fd9a7ed2c6d8 Log: Adding a way of deriving the cgi executable from the cli. Matches current impl but will need win specific test Changed paths: M src/configuration/rtRuntestsConfiguration.php M src/configuration/settings/rtPhpCgiExecutableSetting.php M tests/configuration/settings/rtPhpCgiExecutableSettingTest.php Diff: diff --git a/src/configuration/rtRuntestsConfiguration.php b/src/configuration/rtRuntestsConfiguration.php index cc58310..036ecdb 100644 --- a/src/configuration/rtRuntestsConfiguration.php +++ b/src/configuration/rtRuntestsConfiguration.php @@ -104,7 +104,13 @@ abstract class rtRuntestsConfiguration * */ 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(); } diff --git a/src/configuration/settings/rtPhpCgiExecutableSetting.php b/src/configuration/settings/rtPhpCgiExecutableSetting.php index 47f0912..30ac22c 100644 --- a/src/configuration/settings/rtPhpCgiExecutableSetting.php +++ b/src/configuration/settings/rtPhpCgiExecutableSetting.php @@ -33,6 +33,18 @@ class rtPhpCgiExecutableSetting extends rtSetting } } + /** + * + */ + public function setFromPhpCli($phpCli) + { + if(substr(dirname($phpCli),-3) == 'cli') { + $pathLength = strlen(dirname($phpCli)) - 3; + $sapiDir = substr(dirname($phpCli), 0, $pathLength); + $this->phpCgiExecutable = $sapiDir."cgi/php"; + } + } + /** * Supply the setting to the configuration on request diff --git a/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php b/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php index 9bbfd09..2c5e645 100644 --- a/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php +++ b/tests/configuration/settings/rtPhpCgiExecutableSettingTest.php @@ -25,10 +25,18 @@ class rtPhpCgiExecutableSettingTest extends PHPUnit_Framework_TestCase public function testSetPhpCgiExecutableNotSet() { $configuration = rtRuntestsConfiguration::getInstance(array('run-tests.php', 'test.phpt')); - + $cgisetting = new rtPhpCgiExecutableSetting($configuration); + + $this->assertEquals(null, $cgisetting->get()); + } + + public function testSetFromCliExecutableName() { - $this->assertEquals(null, $cgisetting->get()); + $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')); } } ?>

« previous php.qa (#66523) next »