zoe             Wed Jul  1 20:15:41 2009 UTC

  Modified files:              
    /phpruntests/src/testcase   rtPhpTest.php 
  Log:
  Changes to deal with parsing tests that contain section key words  inside teh 
section
  
http://cvs.php.net/viewvc.cgi/phpruntests/src/testcase/rtPhpTest.php?r1=1.11&r2=1.12&diff_format=u
Index: phpruntests/src/testcase/rtPhpTest.php
diff -u phpruntests/src/testcase/rtPhpTest.php:1.11 
phpruntests/src/testcase/rtPhpTest.php:1.12
--- phpruntests/src/testcase/rtPhpTest.php:1.11 Tue Jun  2 19:12:07 2009
+++ phpruntests/src/testcase/rtPhpTest.php      Wed Jul  1 20:15:41 2009
@@ -40,29 +40,40 @@
      */
     public function parse()
     {
-        for ($i=0; $i<count($this->contents); $i++) {
-            //Create an array of section objects
-            if ($this->isSectionKey($this->contents[$i])) {
-                $sectionKey = $this->contents[$i];
-
-                $tempArray = array();
-                for ($j=$i+1; $j<count($this->contents); $j++) {
-                     
-                    if ($this->isSectionKey($this->contents[$j]) || 
stripos($this->contents[$j], "===done===") !== false) {
-                        if(stripos($this->contents[$j], "===done===") !== 
false) {
-                            $tempArray[] = trim($this->contents[$j]);
+
+        for ($sectionCount = 0; $sectionCount < count ($this->sectionHeadings) 
-1 ; $sectionCount++) {
+
+            $sectionKey = $this->sectionHeadings[$sectionCount];
+            $nextSectionKey = $this->sectionHeadings[$sectionCount + 1];
+            $tempArray = array();
+            
+            $contentPointer = 0;
+            for ($i=0; $i<count($this->contents); $i++) {
+                if($this->contents[$i] == $sectionKey) {
+                    for ($j=$i+1; $j<count($this->contents); $j++) {
+                        if ($this->contents[$j] == $nextSectionKey || 
stripos($this->contents[$j], "===done===") !== false) {
+                            if(stripos($this->contents[$j], "===done===") !== 
false) {
+                                $tempArray[] = trim($this->contents[$j]);
+                            }
+ 
+                            $testSection = rtSection::getInstance($sectionKey, 
$tempArray);
+                            $this->sections[$sectionKey] = $testSection;
+                            $contentPointer = $j;
+                            break;
                         }
-                        $testSection = rtSection::getInstance($sectionKey, 
$tempArray);
-                        $this->sections[$sectionKey] = $testSection;
-                        break;
+                        $tempArray[] = $this->contents[$j];
                     }
-                    $tempArray[] = $this->contents[$j];
                 }
             }
         }
 
-        $testSection = rtSection::getInstance($sectionKey, $tempArray);
-        $this->sections[$sectionKey] = $testSection;
+        
+        $tempArray = array();
+        for ($k = $contentPointer +1; $k < count($this->contents); $k++) {
+            $tempArray[] = $this->contents[$k];
+        }
+        $testSection = rtSection::getInstance($nextSectionKey, $tempArray);
+        $this->sections[$nextSectionKey] = $testSection;
         
 
         //Identify the file and expect section types
@@ -71,23 +82,23 @@
 
         $this->fileSection->setExecutableFileName($this->getName());
     }
-    
+
 
     /**
      * Initialises the configuration for this test. Uses the configuration 
sections from teh test case
-     * 
+     *
      * @param rtRunTEstsConfiuration $runConfiguration
-     * 
+     *
      */
     public function init(rtRuntestsConfiguration $runConfiguration)
     {
         $this->testConfiguration = new rtTestConfiguration($runConfiguration, 
$this->sections, $this->sectionHeadings, $this->fileSection);
     }
-    
+
 
     /**
      * Executes the test case
-     * 
+     *
      * @param rtRunTEstsConfiuration $runConfiguration
      */
     public function executeTest(rtRuntestsConfiguration $runConfiguration)
@@ -119,7 +130,7 @@
 
     /**
      * Test the output against the expect section
-     * 
+     *
      */
     public function compareOutput()
     {
@@ -132,10 +143,10 @@
         }
     }
 
-    
+
     /**
      * Test the expected headers against actual headers. Only relevant for CGI 
tests.
-     * 
+     *
      */
     public function compareHeaders()
     {
@@ -148,10 +159,10 @@
         }
     }
 
-    
+
     /**
      * Identify a section heading
-     * 
+     *
      */
     private function isSectionKey($line)
     {
@@ -180,7 +191,7 @@
         }
     }
 
-    
+
     /**
      * Sets the test's expect section
      */
@@ -223,9 +234,9 @@
     {
         return $this->sections[$sectionKey];
     }
-    
+
     /*
-     * Return the object containing all test status 
+     * Return the object containing all test status
      */
     public function getStatus()
     {



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

Reply via email to