com phpruntests: adding in extended class: src/testcase/sections/executablesections/rtFileExternalSection.php
| From: | David Soria Parra | Date: | Sun, 17 May 2009 10:36:44 +0000 |
| Subject: | com phpruntests: adding in extended class: src/testcase/sections/executablesections/rtFileExternalSection.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66455@lists.php.net to get a copy of this message | ||
Commit: 52f744a947d238fc3652da4633d209d8bbd8e6e5
Author: Zoe Slattery <zoe@php.net> Sun, 17 May 2009 10:36:44 +0000
Parents: b69c16330e3937bc0bf5710ee2d3d6c4027f59d9
Branches: master
Link: http://git.php.net/?p=phpruntests.git;a=commitdiff;h=52f744a947d238fc3652da4633d209d8bbd8e6e5
Log:
adding in extended class
Changed paths:
A src/testcase/sections/executablesections/rtFileExternalSection.php
Diff:
diff --git a/src/testcase/sections/executablesections/rtFileExternalSection.php
b/src/testcase/sections/executablesections/rtFileExternalSection.php
new file mode 100644
index 0000000..040d052
--- /dev/null
+++ b/src/testcase/sections/executablesections/rtFileExternalSection.php
@@ -0,0 +1,56 @@
+<?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 rtFileSection
+{
+
+ public function run(rtPhpTest $testCase, rtRuntestsConfiguration $runConfiguration)
+ {
+ if ($this->copyExternalFileContent() === true) {
+
+ return parent::run($testCase, $runConfiguration);
+ }
+
+ return $this->status;
+ }
+
+
+ private function copyExternalFileContent()
+ {
+ if (sizeof($this->sectionContents) == 1) {
+
+ $file = $this->sectionContents[0];
+
+ // don't allow tests to retrieve files from anywhere but this subdirectory
+ $file = dirname($this->fileName).'/'.trim(str_replace('..',
'', $file));
+
+ if (file_exists($file)) {
+
+ $this->sectionContents[0] = file_get_contents($file);
+ return true;
+
+ } else {
+
+ $this->status['fail'] = 'Can not open external file '.$file;
+ }
+
+ } else {
+
+ $this->status['fail'] = 'One file per testcase permitted.';
+ }
+
+ return false;
+ }
+}
+?>