g2              Mon May 18 22:38:27 2009 UTC

  Modified files:              
    /phpruntests/tests/testcase/sections/executablesections     
                                                                
rtFileExternalSectionTest.php 
    /phpruntests/src/testcase/sections/executablesections       
                                                                
rtFileExternalSection.php 
  Log:
  phpruntests - update external-section testcase
  
http://cvs.php.net/viewvc.cgi/phpruntests/tests/testcase/sections/executablesections/rtFileExternalSectionTest.php?r1=1.1&r2=1.2&diff_format=u
Index: 
phpruntests/tests/testcase/sections/executablesections/rtFileExternalSectionTest.php
diff -u 
phpruntests/tests/testcase/sections/executablesections/rtFileExternalSectionTest.php:1.1
 
phpruntests/tests/testcase/sections/executablesections/rtFileExternalSectionTest.php:1.2
--- 
phpruntests/tests/testcase/sections/executablesections/rtFileExternalSectionTest.php:1.1
    Fri May 15 23:11:20 2009
+++ 
phpruntests/tests/testcase/sections/executablesections/rtFileExternalSectionTest.php
        Mon May 18 22:38:27 2009
@@ -7,7 +7,7 @@
 {
     public function testCreateInstance()
     {
-        $fileSection = new rtFileExternalSection('FILE_EXTERNAL', 
array('<?php', 'echo "hello world";', '?>'));
+        $fileSection = rtFileExternalSection::getInstance('FILE_EXTERNAL', 
array('<?php', 'echo "hello world";', '?>'));
         $code = $fileSection->getContents();
 
         $this->assertEquals('<?php', $code[0]);
@@ -15,41 +15,25 @@
     
     public function testTooMuchFiles()
     {
-        $wrapper = new rtFileExternalSectionTestWrapper('FILE_EXTERNAL', 
array('file1','file2'));
-       
-        $this->assertFalse($wrapper->copyExternalFileContentTest());
-        
-        $status = $wrapper->getStatus();
+        $fileSection = rtFileExternalSection::getInstance('FILE_EXTERNAL', 
array('file1','file2'));
+       $content = $fileSection->getContents();
+       $config = rtRuntestsConfiguration::getInstance(array());
+       $test = new rtPhpTest($content, 'TEST', array('FILE_EXTERNAL'), 
$config);
+
+       $status = $fileSection->run($test, $config);
 
         $this->assertEquals('One file per testcase permitted.', 
$status['fail']);
     }
     
     public function testNotExistingFile()
     {
-        $wrapper = new rtFileExternalSectionTestWrapper('FILE_EXTERNAL', 
array('file1'));
-        
-        $this->assertFalse($wrapper->copyExternalFileContentTest());
-        
-        $status = $wrapper->getStatus();
+        $fileSection = rtFileExternalSection::getInstance('FILE_EXTERNAL', 
array('file1'));
+        $content = $fileSection->getContents();
+        $config = rtRuntestsConfiguration::getInstance(array());
+        $test = new rtPhpTest($content, 'TEST', array('FILE_EXTERNAL'), 
$config);
 
         $this->assertEquals('Can not open external file /file1', 
$status['fail']);
     }
 }
 
-/**
- * test-wrapper to acces protected methods and members
- */
-class rtFileExternalSectionTestWrapper extends rtFileExternalSection
-{
-    public function copyExternalFileContentTest()
-    {
-       return parent::copyExternalFileContent();
-    }
-
-    public function getStatus()
-    {
-        return $this->status;
-    }
-}
-
 ?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php?r1=1.5&r2=1.6&diff_format=u
Index: 
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php
diff -u 
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php:1.5
 
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php:1.6
--- 
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php:1.5
  Sun May 17 11:47:27 2009
+++ 
phpruntests/src/testcase/sections/executablesections/rtFileExternalSection.php  
    Mon May 18 22:38:27 2009
@@ -14,43 +14,41 @@
  */
 class rtFileExternalSection extends rtFileSection
 {
-
+       /**
+        * @param  rtPhpTest                $testCase
+        * @param  rtRuntestsConfiguration  $runConfiguration
+        * @return Array                    $status
+        */
     public function run(rtPhpTest $testCase, rtRuntestsConfiguration 
$runConfiguration)
     {
        if ($this->copyExternalFileContent() === true) {
-
             return parent::run($testCase, $runConfiguration);
         }
-
         return $this->status;
     }
 
-    
+    /**
+     * @return boolean
+     */
     private function copyExternalFileContent()
     {
-       if (sizeof($this->sectionContents) == 1) {
+       if (sizeof($this->sectionContents) != 1) {
+            $this->status['fail'] = 'One file per testcase permitted.';
+           return false;
+       }
        
-               $file = $this->sectionContents[0];
-               
-               // don't allow tests to retrieve files from anywhere but this 
subdirectory
-               $file = dirname($this->fileName).'/'.trim(str_replace('..', '', 
$file));
+        $file = $this->sectionContents[0];
                
-               if (file_exists($file)) {
+           // don't allow tests to retrieve files from anywhere but this 
subdirectory
+        $file = dirname($this->fileName).'/'.trim(str_replace('..', '', 
$file));
                
-                   $this->sectionContents[0] = file_get_contents($file);       
     
-                   return true;
+        if (!file_exists($file)) {
+              $this->status['fail'] = 'Can not open external file '.$file;
+              return false;
+        }
                
-               } else {
-                       
-                       $this->status['fail'] = 'Can not open external file 
'.$file;
-               }
-        
-       } else {
-               
-               $this->status['fail'] = 'One file per testcase permitted.';
-       }
-        
-        return false;
+        $this->sectionContents[0] = file_get_contents($file);            
+        return true;
     }
     
     public function writeExecutableFile() {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to