cvs: phpruntests /src/testcase/sections/executablesections rtFileExternalSection.php

From: Date: Sun, 17 May 2009 10:36:44 +0000
Subject: cvs: phpruntests /src/testcase/sections/executablesections rtFileExternalSection.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-57907@lists.php.net to get a copy of this message
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 <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; + } +} +?>

« previous php.cvs (#57907) next »