com phpruntests: Deleting duplicated code: src/testcase/sections/executablesections/rtFileExternalSection.php
| From: | David Soria Parra | Date: | Sun, 17 May 2009 10:36:05 +0000 |
| Subject: | com phpruntests: Deleting duplicated code: src/testcase/sections/executablesections/rtFileExternalSection.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66456@lists.php.net to get a copy of this message | ||
Commit: b69c16330e3937bc0bf5710ee2d3d6c4027f59d9
Author: Zoe Slattery <zoe@php.net> Sun, 17 May 2009 10:36:05 +0000
Parents: 8616086585fb1c3534be6713ab59b307402b0198
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=b69c16330e3937bc0bf5710ee2d3d6c4027f59d9
Log:
Deleting duplicated code
Changed paths:
D src/testcase/sections/executablesections/rtFileExternalSection.php
Diff:
diff --git a/src/testcase/sections/executablesections/rtFileExternalSection.php
b/src/testcase/sections/executablesections/rtFileExternalSection.php
deleted file mode 100644
index 7cc3dac..0000000
--- a/src/testcase/sections/executablesections/rtFileExternalSection.php
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-/**
- * rtFileExternalSection
- * Executes the code in the --FILE_EXTERNAL-- section
- *
- * @category Testing
- * @package RUNTESTS
- * @author Zoe Slattery <zoe@php.net>
- * @author Stefan Priebsch <spriebsch@php.net>
- * @author Georg Gradwohl <g2@php.net>
- * @copyright 2009 The PHP Group
- * @license http://www.php.net/license/3_01.txt
PHP License 3.01
- * @link http://qa.php.net/
- */
-class rtFileExternalSection extends rtExecutableSection
-{
-
- /**
- * @var $twoBlankLines string
- */
- private $twoBlankLines = '\r?\n\r?\n';
-
- /**
- * sets the executable filename
- *
- * @param $testName string the filename
- * @return void
- */
- public function setExecutableFileName($testName)
- {
- $this->fileName = $testName.".php";
- }
-
- /**
- * runs a test-case and returns the status
- *
- * @param $testCase rtPhpTest
- * @param $runConfiguration rtRuntestsConfiguration
- * @return $status Array
- */
- public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration)
- {
- $this->status = array();
- $this->writeExecutableFile();
-
- $this->copyExternalFileContent();
-
- $phpExecutable = $testCase->testConfiguration->getPhpExecutable();
-
- // The CGI excutable is null if it is not available, check and SKIP if necessary
- if (is_null($phpExecutable)) {
- $this->status['skip'] = 'The CGI executable is unavailable';
- return $this->status;
- }
-
- $phpCommand = $phpExecutable;
- $phpCommand .= ' '.
$testCase->testConfiguration->getPhpCommandLineArguments();
- $phpCommand .= ' -f '.$this->fileName;
- $phpCommand .= '
'.$testCase->testConfiguration->getTestCommandLineArguments();
- $phpCommand .= ' 2>&1
'.$testCase->testConfiguration->getInputFileString();
-
-
- $PhpRunner = new rtPhpRunner($phpCommand,
- $testCase->testConfiguration->getEnvironmentVariables(),
- $runConfiguration->getSetting('WorkingDirectory')
- );
-
- try {
-
- $this->output = $PhpRunner->runphp();
-
- // If it's a CGI test sort the headers out here
- if (substr($phpExecutable, -2) == '-C') {
-
- if (preg_match("/^(.*?)$this->twoBlankLines(.*)/s", $this->output,
$match)) {
- $this->output = $match[2];
- $this->headers = $match[1];
- }
- }
- } catch (rtPhpRunnerException $e) {
-
- $this->status['fail'] = $e->getMessage();
- }
-
- return $this->status;
- }
-
- /**
- * @return string
- */
- public function getHeaders()
- {
- return $this->headers;
- }
-
- /**
- * checks and copies the content of the external file to the testfile
- *
- * @return boolean
- */
- protected function copyExternalFileContent()
- {
- if (sizeof($this->sectionContents) != 1) {
-
- $this->status['fail'] = 'One file per testcase permitted.';
- return false;
- }
-
- $c = $this->sectionContents[0];
-
- // don't allow tests to retrieve files from anywhere but this subdirectory
- $file = dirname($this->fileName).'/'.trim(str_replace('..',
'', $c));
-
- if (!file_exists($file)) {
-
- $this->status['fail'] = 'Can not open external file '.$file;
- return false;
- }
-
- $content = file_get_contents($file);
- file_put_contents($this->fileName, $content);
- return true;
- }
-}
-?>