zoe Sun May 17 10:36:44 2009 UTC
Modified files:
/phpruntests/src/testcase/sections/executablesections
rtFileExternalSection.php
Log:
adding in extended class
http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php?r1=1.3&r2=1.4&diff_format=u
Index:
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php
diff -u /dev/null
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php:1.4
--- /dev/null Sun May 17 10:36:44 2009
+++
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php
Sun May 17 10:36:44 2009
@@ -0,0 +1,56 @@
+<?php
+/**
+ * rtFileExternalSection
+ * Executes the code in the --FILE_EXTERNAL-- section
+ *
+ * @category Testing
+ * @package RUNTESTS
+ * @author Zoe Slattery <[email protected]>
+ * @author Stefan Priebsch <[email protected]>
+ * @author Georg Gradwohl <[email protected]>
+ * @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;
+ }
+}
+?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php