[limb-svn] r6281 - in 3.x/trunk/limb/macro: src tests/cases

svn at limb-project.com svn at limb-project.com
Mon Sep 10 09:57:50 MSD 2007


Author: pachanga
Date: 2007-09-10 09:57:50 +0400 (Mon, 10 Sep 2007)
New Revision: 6281
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6281

Modified:
   3.x/trunk/limb/macro/src/lmbMacroNode.class.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroTagTest.class.php
Log:
-- fixing regression bugs(wrap test still fails)

Modified: 3.x/trunk/limb/macro/src/lmbMacroNode.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroNode.class.php	2007-09-10 05:14:49 UTC (rev 6280)
+++ 3.x/trunk/limb/macro/src/lmbMacroNode.class.php	2007-09-10 05:57:50 UTC (rev 6281)
@@ -93,9 +93,8 @@
 
   function removeChild($id)
   {
-    foreach(array_keys($this->children) as $key)
+    foreach($this->children as $key => $child)
     {
-      $child = $this->children[$key];
       if($child->getId() == $id)
       {
         unset($this->children[$key]);
@@ -111,10 +110,10 @@
 
   function removeChildren()
   {
-    foreach (array_keys($this->children) as $key)
+    foreach($this->children as $child)
     {
-      $this->children[$key]->removeChildren();
-      unset($this->children[$key]);
+      $child->removeChildren();
+      unset($child);
     }
   }
 
@@ -128,24 +127,24 @@
 
   function findChild($id)
   {
-    foreach(array_keys($this->children) as $key)
+    foreach($this->children as $child)
     {
-      if($this->children[$key]->getId() == $id)
-        return $this->children[$key];
+      if($child->getId() == $id)
+        return $child;
       else
-        return $this->children[$key]->findChild($id);          
+        return $child->findChild($id);          
     }
   }
 
   function findChildByClass($class)
   {
-    foreach(array_keys($this->children) as $key)
+    foreach($this->children as $child)
     {
-      if(is_a($this->children[$key], $class))
-        return $this->children[$key];
+      if(is_a($child, $class))
+        return $child;
       else
       {
-        if($result = $this->children[$key]->findChildByClass($class))
+        if($result = $child->findChildByClass($class))
           return $result;
       }
     }
@@ -154,13 +153,13 @@
   function findChildrenByClass($class)
   {
     $ret = array();
-    foreach(array_keys($this->children) as $key)
+    foreach($this->children as $child)
     {
-      if(is_a($this->children[$key], $class))
-        $ret[] = $this->children[$key];
+      if(is_a($child, $class))
+        $ret[] = $child;
       else
       {
-        $more_children = $this->children[$key]->findChildrenByClass($class);
+        $more_children = $child->findChildrenByClass($class);
         if(count($more_children))
           $ret = array_merge($ret, $more_children);
       }
@@ -170,20 +169,20 @@
 
   function findImmediateChildByClass($class)
   {
-    foreach(array_keys($this->children) as $key)
+    foreach($this->children as $child)
     {
-      if(is_a($this->children[$key], $class))
-        return $this->children[$key];
+      if(is_a($child, $class))
+        return $child;
     }
   }
 
   function findImmediateChildrenByClass($class)
   {
     $result = array();
-    foreach(array_keys($this->children) as $key)
+    foreach($this->children as $child)
     {
-      if(is_a($this->children[$key], $class))
-        $result[] = $this->children[$key];
+      if(is_a($child, $class))
+        $result[] = $child;
     }
     return $result;
   }  
@@ -200,22 +199,22 @@
   
   function prepare()
   {
-    foreach(array_keys($this->children) as $key)
-      $this->children[$key]->prepare();
+    foreach($this->children as $child)
+      $child->prepare();
   }  
 
   function preParse(){}
   
   function generateConstructor($code_writer)
   {
-    foreach(array_keys($this->children) as $key)
-      $this->children[$key]->generateConstructor($code_writer);
+    foreach($this->children as $child)
+      $child->generateConstructor($code_writer);
   }
 
   function generateContents($code_writer)
   {
-    foreach(array_keys($this->children) as $key)
-      $this->children[$key]->generate($code_writer);
+    foreach($this->children as $child)
+      $child->generate($code_writer);
   }
   
   function generate($code_writer)
@@ -234,7 +233,7 @@
     foreach($this->getChildren() as $key => $child)
     {
       $id = $child->getId();
-      if (in_array($id, $child_ids))
+      if(in_array($id, $child_ids))
       {
         $duplicate_child = $checked_children[$id];
         $child->raise('Duplicate "id" attribute',

Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagTest.class.php	2007-09-10 05:14:49 UTC (rev 6280)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagTest.class.php	2007-09-10 05:57:50 UTC (rev 6281)
@@ -12,12 +12,14 @@
 lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
 lmb_require('limb/macro/src/lmbMacroSourceLocation.class.php');
 lmb_require('limb/macro/src/lmbMacroCodeWriter.class.php'); 
+lmb_require('limb/macro/src/lmbMacroCompiler.class.php'); 
  
 class MacroTagClass1CompilerTest extends lmbMacroTag{}
 class MacroTagClass2CompilerTest extends lmbMacroTag{}
 
 Mock::generate('lmbMacroNode', 'MockMacroNode');
 Mock::generate('lmbMacroCodeWriter', 'MockMacroCodeWriter');
+Mock::generate('lmbMacroCompiler', 'MockMacroCompiler');
 
 class lmbMacroTagTest extends UnitTestCase
 {
@@ -276,7 +278,7 @@
   {
     $this->tag_info->setRequiredAttributes(array('bar'));
     $this->node->set('bar', null);
-    $this->node->preParse();
+    $this->node->preParse(new MockMacroCompiler());
   }
 
   function testPreparseAndCheckForMissedRequiredAttributes()
@@ -285,7 +287,7 @@
 
     try
     {
-      $this->node->preParse();
+      $this->node->preParse(new MockMacroCompiler());
       $this->assertTrue(false);
     }
     catch(lmbMacroException $e)
@@ -307,7 +309,7 @@
 
     try
     {
-      $node->preParse();
+      $node->preParse(new MockMacroCompiler());
       $this->assertTrue(false);
     }
     catch(lmbMacroException $e)
@@ -325,7 +327,7 @@
     $parent = new MacroTagClass1CompilerTest(null, null, null);
     $this->node->setParent($parent);
 
-    $this->node->preParse();
+    $this->node->preParse(new MockMacroCompiler());
   }
 
   function testCheckParentTagClassException()
@@ -337,7 +339,7 @@
 
     try
     {
-      $this->node->preParse();
+      $this->node->preParse(new MockMacroCompiler());
       $this->assertTrue(false);
     }
     catch(lmbMacroException $e)



More information about the limb-svn mailing list