[limb-svn] r6020 - in 3.x/trunk/limb/tests_runner: src tests/cases

svn at limb-project.com svn at limb-project.com
Wed Jun 27 19:12:32 MSD 2007


Author: pachanga
Date: 2007-06-27 19:12:32 +0400 (Wed, 27 Jun 2007)
New Revision: 6020
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6020

Added:
   3.x/trunk/limb/tests_runner/src/lmbTestFileRunner.class.php
   3.x/trunk/limb/tests_runner/tests/cases/lmbTestFileRunnerTest.class.php
   3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeNodeTest.class.php
Removed:
   3.x/trunk/limb/tests_runner/src/lmbTestTree.class.php
   3.x/trunk/limb/tests_runner/tests/cases/lmbTestRunnerTest.class.php
   3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeTest.class.php
Modified:
   3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestTreeDirNode.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestTreeGlobNode.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestTreeNode.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestTreePath.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestTreeTerminalNode.class.php
   3.x/trunk/limb/tests_runner/src/lmbTestWebUI.class.php
   3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeDirNodeTest.class.php
Log:
-- major TESTS_RUNNER simplification and refactoring:
 * lmbTestTreeNode is now not abstract and can be instantiated
 * lmbTestTreeNode :: bootstrap() => init()
 * lmbTestTreeNode :: bootstrapPath() removed as not needed anymore
 * lmbTestTreeNode :: createTestGroupWithoutChildren(), createTestGroupWithParents(), wrapWithParentTestGroups() removed as not needed anymore
 * lmbTestTreePath now encapsulates a full path to the tesing node in the tree
 * lmbTestTree removed, now lmbTestRunner ensapsulates its functionality
 * lmbTestRunner is more general now, it operates over nodes not files
 * old lmbTestRunner functionality is now encapsulated in new lmbTestFileRunner
 * TR-11 is now resolved nicely

Added: 3.x/trunk/limb/tests_runner/src/lmbTestFileRunner.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestFileRunner.class.php	                        (rev 0)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestFileRunner.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -0,0 +1,119 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+require_once(dirname(__FILE__) . '/lmbTestRunner.class.php');
+
+/**
+ * class lmbTestFileRunner.
+ *
+ * @package tests_runner
+ * @version $Id$
+ */
+class lmbTestFileRunner extends lmbTestRunner
+{
+  protected $tests_found = false;
+
+  function runForFiles($file_path)
+  {
+    if(!is_array($file_path))
+      $test_paths[] = $file_path;
+    else
+      $test_paths = $file_path;
+
+    require_once(dirname(__FILE__) . '/../simpletest.inc.php');
+
+    $this->_startTimer();
+    $this->_startCoverage();
+
+    try
+    {
+      $res = $this->_doRunForFiles($test_paths);
+    }
+    catch(Exception $e)
+    {
+      $this->_showException($e);
+      return false;
+    }
+
+    $this->_endCoverage();
+    $this->_stopTimer();
+    return $res;
+  }
+
+  protected function _doRunForFiles($test_paths)
+  {
+    $this->tests_found = false;
+    $res = true;
+    foreach($test_paths as $test_path)
+    {
+      foreach(glob($this->_normalizePath($test_path)) as $file)
+      {
+        $this->tests_found = true;
+        $root_dir = $this->_getRootDir($file);
+        $path = $this->_mapFileToNode($root_dir, $file);
+        $node = $this->_initDirNode($root_dir);
+        $res = $res & $this->_doRun($node, $path);
+      }
+    }
+    return $res;
+  }
+
+  function testsFound()
+  {
+    return $this->tests_found;
+  }
+
+  protected function _normalizePath($path)
+  {
+    if($this->_isAbsolutePath($path))
+      return rtrim($path, '\\/');
+    else
+      return rtrim($this->_getcwd() . DIRECTORY_SEPARATOR . $path, '\\/');
+  }
+
+  /**
+   * Due to require_once error in PHP before 5.2 version this method 'strtolowers' paths under windows
+   */
+  protected function _getcwd()
+  {
+    $wd = getcwd();
+    //win32 check
+    if(DIRECTORY_SEPARATOR == '\\')
+      $wd = strtolower($wd);
+    return $wd;
+  }
+
+  protected function _isAbsolutePath($path)
+  {
+    return $path{0} == '/' || preg_match('~^[a-z]:~i', $path);
+  }
+
+  protected function _initDirNode($dir)
+  {
+    require_once(dirname(__FILE__) . '/lmbTestTreeDirNode.class.php');
+    return new lmbTestTreeDirNode($dir);
+  }
+
+  protected function _mapFileToNode($root_dir, $file)
+  {
+    require_once(dirname(__FILE__) . '/lmbFile2TestNodeMapper.class.php');
+    $mapper = new lmbFile2TestNodeMapper();
+    return $mapper->map($root_dir, $file);
+  }
+
+  protected function _getRootDir($file)
+  {
+    $path_items = explode(DIRECTORY_SEPARATOR, $file);
+    //windows/linux filesystem paths style check
+    return empty($path_items[0]) ?
+              DIRECTORY_SEPARATOR . $path_items[1] :  //unix
+              $path_items[0] . DIRECTORY_SEPARATOR;   //windows
+  }
+}
+
+?>
\ No newline at end of file

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -15,7 +15,6 @@
  */
 class lmbTestRunner
 {
-  protected $test_paths = array();
   protected $reporter;
   protected $coverage;
   protected $coverage_reporter;
@@ -25,14 +24,6 @@
   protected $start_time = 0;
   protected $end_time = 0;
 
-  function __construct($test_path)
-  {
-    if(!is_array($test_path))
-      $this->test_paths[] = $test_path;
-    else
-      $this->test_paths = $test_path;
-  }
-
   function setReporter($reporter)
   {
     $this->reporter = $reporter;
@@ -45,35 +36,50 @@
     $this->coverage_report_dir = $coverage_report_dir;
   }
 
-  function run(&$tests_found = false)
+  function run($root_node, $path)
   {
+    require_once(dirname(__FILE__) . '/../simpletest.inc.php');
+
     $this->_startTimer();
     $this->_startCoverage();
-    $res = $this->_runForTestPath($tests_found);
+
+    try
+    {
+      $res = $this->_doRun($root_node, $path);
+    }
+    catch(Exception $e)
+    {
+      $this->_showException($e);
+      return false;
+    }
+
     $this->_endCoverage();
     $this->_stopTimer();
     return $res;
   }
 
-  protected function _runForTestPath(&$tests_found = false)
+  protected function _doRun($node, $path)
   {
-    require_once(dirname(__FILE__) . '/../simpletest.inc.php');
+    if(!$tree_path = $node->objectifyPath($path))
+      throw new Exception("Test node '$path' not found!");
 
-    $res = true;
-    foreach($this->test_paths as $test_path)
+    if($node = $tree_path->getSkippedNode())
     {
-      foreach(glob($this->_normalizePath($test_path)) as $file)
-      {
-        $tests_found = true;
-        $root_dir = $this->_getRootDir($file);
-        $node = $this->_mapFileToNode($root_dir, $file);
-        $tree = $this->_initTree($root_dir);
-        $res = $res & $tree->perform($node, $this->_getReporter());
-      }
+      echo "(There's a skipped test node in a path, skipping execution)\n";
+      return true;
     }
-    return $res;
+
+    $tree_path->init();
+
+    $test = $tree_path->createTestGroup();
+    return $test->run($this->_getReporter());
   }
 
+  protected function _showException($e)
+  {
+    echo $e->__toString();
+  }
+
   protected function _startTimer()
   {
     $this->start_time = microtime(true);
@@ -117,54 +123,6 @@
     }
   }
 
-  protected function _normalizePath($path)
-  {
-    if($this->_isAbsolutePath($path))
-      return rtrim($path, '\\/');
-    else
-      return rtrim($this->_getcwd() . DIRECTORY_SEPARATOR . $path, '\\/');
-  }
-
-  /**
-   * Due to require_once error in PHP before 5.2 version this method 'strtolowers' paths under windows
-   */
-  protected function _getcwd()
-  {
-    $wd = getcwd();
-    //win32 check
-    if(DIRECTORY_SEPARATOR == '\\')
-      $wd = strtolower($wd);
-    return $wd;
-  }
-
-  protected function _isAbsolutePath($path)
-  {
-    return $path{0} == '/' || preg_match('~^[a-z]:~i', $path);
-  }
-
-  protected function _initTree($root_node)
-  {
-    require_once(dirname(__FILE__) . '/lmbTestTree.class.php');
-    require_once(dirname(__FILE__) . '/lmbTestTreeDirNode.class.php');
-    return new lmbTestTree(new lmbTestTreeDirNode($root_node));
-  }
-
-  protected function _mapFileToNode($root_dir, $file)
-  {
-    require_once(dirname(__FILE__) . '/lmbFile2TestNodeMapper.class.php');
-    $mapper = new lmbFile2TestNodeMapper();
-    return $mapper->map($root_dir, $file);
-  }
-
-  protected function _getRootDir($file)
-  {
-    $path_items = explode(DIRECTORY_SEPARATOR, $file);
-    //windows/linux filesystem paths style check
-    return empty($path_items[0]) ?
-              DIRECTORY_SEPARATOR . $path_items[1] :  //unix
-              $path_items[0] . DIRECTORY_SEPARATOR;   //windows
-  }
-
   protected function _getReporter()
   {
     if(!$this->reporter)

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -7,7 +7,7 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 require_once(dirname(__FILE__) . '/lmbTestGetopt.class.php');
-require_once(dirname(__FILE__) . '/lmbTestRunner.class.php');
+require_once(dirname(__FILE__) . '/lmbTestFileRunner.class.php');
 
 /**
  * class lmbTestShellUI.
@@ -185,7 +185,7 @@
     if(!$cover_report_dir && defined('LIMB_TESTS_RUNNER_COVERAGE_REPORT_DIR'))
       $cover_report_dir = LIMB_TESTS_RUNNER_COVERAGE_REPORT_DIR;
 
-    $runner = new lmbTestRunner($options[1]);
+    $runner = new lmbTestFileRunner();
 
     if($this->reporter)
       $runner->setReporter($this->reporter);
@@ -194,9 +194,9 @@
       $runner->useCoverage($cover_include, $cover_exclude, $cover_report_dir);
 
     $found = false;
-    $res = $runner->run($found);
+    $res = $runner->runForFiles($options[1]);
 
-    if(!$found)
+    if(!$runner->testsFound())
       $this->_error("No tests were found\n");
 
     echo $runner->getRuntime() . " sec.\n";

Deleted: 3.x/trunk/limb/tests_runner/src/lmbTestTree.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTree.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTree.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -1,62 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-/**
- * class lmbTestTree.
- *
- * @package tests_runner
- * @version $Id$
- */
-class lmbTestTree
-{
-  protected $root_node;
-
-  function __construct($root_node)
-  {
-    $this->root_node = $root_node;
-  }
-
-  function find($path)
-  {
-    $node = $this->root_node->findChildByPath($path);
-    $this->root_node->bootstrapPath($path);
-    return $node;
-  }
-
-  function perform($path, $reporter)
-  {
-    try
-    {
-      return $this->_doPerform($path, $reporter);
-    }
-    catch(Exception $e)
-    {
-      $this->_showException($e);
-      return false;
-    }
-  }
-
-  protected function _doPerform($path, $reporter)
-  {
-    if(!$node = $this->find($path))
-      throw new Exception("Test node '$path' not found!");
-
-    $test = $node->createTestGroupWithParents();
-    $res = $test->run($reporter);
-
-    return $res;
-  }
-
-  protected function _showException($e)
-  {
-    echo $e->__toString();
-  }
-}
-
-?>
\ No newline at end of file

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestTreeDirNode.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTreeDirNode.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTreeDirNode.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -13,8 +13,8 @@
 require_once(dirname(__FILE__) . '/lmbTestFileFilter.class.php');
 require_once(dirname(__FILE__) . '/lmbTestTreePath.class.php');
 
- at define('LIMB_TEST_RUNNER_FILE_FILTER', '*Test.class.php;*.test.php;*_test.php');
- at define('LIMB_TEST_RUNNER_CLASS_FORMAT', '%s.class.php');
+ at define('LIMB_TESTS_RUNNER_FILE_FILTER', '*Test.class.php;*.test.php;*_test.php');
+ at define('LIMB_TESTS_RUNNER_CLASS_FORMAT', '%s.class.php');
 
 /**
  * class lmbTestTreeDirNode.
@@ -31,15 +31,13 @@
   protected $loaded;
   protected $skipped;
 
-  function __construct($dir, $file_filter = LIMB_TEST_RUNNER_FILE_FILTER, $class_format = LIMB_TEST_RUNNER_CLASS_FORMAT)
+  function __construct($dir, $file_filter = LIMB_TESTS_RUNNER_FILE_FILTER, $class_format = LIMB_TESTS_RUNNER_CLASS_FORMAT)
   {
     if(!is_dir($dir))
       throw new Exception("'$dir' is not a directory!");
 
     $this->dir = $dir;
-
     $this->file_filter = $this->_createFileFilter($file_filter);
-
     $this->class_format = $class_format;
   }
 
@@ -56,50 +54,50 @@
 
   function getTestLabel()
   {
-    $group = $this->createTestGroupWithoutChildren();
+    $group = $this->_createTestGroupWithoutChildren();
     return $group->getLabel();
   }
 
-  function bootstrap()
+  function init()
   {
-    if($this->isSkipped())
-      return false;
-
     if(file_exists($this->dir . '/.init.php'))
       include_once($this->dir . '/.init.php');
-
-    return true;
   }
 
+  //TODO: why having $test_group as a property?
   function createTestGroup()
   {
     if(is_object($this->test_group))
       return $this->test_group;
 
-    $this->test_group = $this->createTestGroupWithoutChildren();
+    $this->test_group = $this->_createTestGroupWithoutChildren();
+    $this->_addChildrenTestCases($this->test_group);
 
-    if($this->bootstrap())
-      $this->_addChildrenTestCases($this->test_group);
-
     return $this->test_group;
   }
 
-  function createTestGroupWithoutChildren()
+  protected function _createTestGroupWithoutChildren()
   {
-    if(!$this->bootstrap())
-      return new lmbTestGroup();
-
     $label = $this->_getDirectoryLabel();
-
     $group = new lmbTestGroup($label);
-
     $fixture = new lmbDetachedFixture($this->dir . '/.setup.php',
                                       $this->dir . '/.teardown.php');
     $group->useFixture($fixture);
-
     return $group;
   }
 
+  protected function _addChildrenTestCases($group)
+  {
+    foreach($this->getChildren() as $child)
+    {
+      if(!$child->isSkipped())
+      {
+        $child->init();
+        $group->addTestCase($child->createTestGroup());
+      }
+    }
+  }
+
   protected function _getDirectoryLabel()
   {
     if(file_exists($this->dir . '/.description'))
@@ -118,28 +116,19 @@
       return new lmbTestFileFilter(explode(';', $file_filter));
   }
 
-  protected function _addChildrenTestCases($group)
-  {
-    foreach($this->getChildren() as $child)
-      $group->addTestCase($child->createTestGroup());
-  }
-
   function _loadLazyChildren()
   {
     if(!is_null($this->loaded) && $this->loaded)
       return;
 
-    if($this->bootstrap())
-    {
-      $dir_items = $this->getDirItems();
+    $dir_items = $this->getDirItems();
 
-      foreach($dir_items as $item)
-      {
-        if(is_dir($item))
-          $this->addChild(new lmbTestTreeDirNode($item, $this->file_filter, $this->class_format));
-        else
-          $this->addChild(new lmbTestTreeFileNode($item, $this->_extractClassName($item)));
-      }
+    foreach($dir_items as $item)
+    {
+      if(is_dir($item))
+        $this->addChild(new lmbTestTreeDirNode($item, $this->file_filter, $this->class_format));
+      else
+        $this->addChild(new lmbTestTreeFileNode($item, $this->_extractClassName($item)));
     }
     $this->loaded = true;
   }

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestTreeGlobNode.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTreeGlobNode.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTreeGlobNode.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -31,19 +31,6 @@
   {
     return 'All ' . $this->glob . ' tests ';
   }
-
-  function createTestGroup()
-  {
-    $group = new TestSuite();
-    foreach($this->children as $child)
-      $group->addTestCase($child->createTestGroup());
-    return $group;
-  }
-
-  function createTestGroupWithoutChildren()
-  {
-    return new TestSuite();
-  }
 }
 
 ?>

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestTreeNode.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTreeNode.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTreeNode.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -13,9 +13,9 @@
  * @package tests_runner
  * @version $Id$
  */
-abstract class lmbTestTreeNode
+class lmbTestTreeNode
 {
-  protected $parent = null;
+  protected $parent;
   protected $children = array();
 
   function setParent($parent)
@@ -39,19 +39,36 @@
     return $this->children;
   }
 
-  function findChildByPath($path)
+  function objectifyPath($path)
   {
-    // return itself in case of / path
-    if(!$array_path = lmbTestTreePath :: toArray($path))
-      return $this;
+    if($this->_traverseArrayPath(lmbTestTreePath :: toArray($path), $nodes))
+    {
+      $tree_path = new lmbTestTreePath();
+      foreach($nodes as $node)
+        $tree_path->addNode($node);
+      return $tree_path;
+    }
+  }
 
-    return $this->_findChildByArrayPath($array_path);
+  function findChildByPath($path)
+  {
+    return $this->_traverseArrayPath(lmbTestTreePath :: toArray($path));
   }
 
-  protected function _findChildByArrayPath($array_path)
+  protected function _traverseArrayPath($array_path, &$nodes = array())
   {
+    $nodes[] = $this;
+
+    // return itself in case of / path
+    if(!$array_path)
+      return $this;
+
     if(sizeof($array_path) == 1)
-      return $this->_getImmediateChildByIndex(array_shift($array_path));
+    {
+      $child = $this->_getImmediateChildByIndex(array_shift($array_path));
+      $nodes[] = $child;
+      return $child;
+    }
 
     $index = array_shift($array_path);
 
@@ -61,7 +78,7 @@
     if($child->isTerminal())
       return null;
 
-    return $child->_findChildByArrayPath($array_path);
+    return $child->_traverseArrayPath($array_path, $nodes);
   }
 
   protected function _getImmediateChildByIndex($index)
@@ -71,70 +88,33 @@
       return $children[$index];
   }
 
-  function isTerminal()
+  function isSkipped()
   {
     return false;
   }
 
-  function isSkipped()
+  function isTerminal()
   {
     return false;
   }
 
-  abstract function createTestGroup();
-
-  abstract function createTestGroupWithoutChildren();
-
-  function bootstrap()
+  function createTestGroup()
   {
-    return true;
+    $group = new TestSuite();
+    foreach($this->children as $child)
+      $group->addTestCase($child->createTestGroup());
+    return $group;
   }
 
-  function bootstrapPath($path)
+  function init()
   {
-    // return itself in case of / path
-    if(!$array_path = lmbTestTreePath :: toArray($path))
-      return $this->bootstrap();
-
-    $reverse_path = array();
-    foreach($array_path as $path_item)
-    {
-      $reverse_path[] = $path_item;
-      if($node = $this->_findChildByArrayPath($reverse_path))
-        $node->bootstrap();
-    }
+    return true;
   }
 
   function getTestLabel()
   {
     return $this->createTestGroup()->getLabel();
   }
-
-  function wrapWithParentTestGroups($case)
-  {
-    $new_group = $this->createTestGroupWithoutChildren();
-    $new_group->addTestCase($case);
-
-    if($parent = $this->getParent())
-      return $parent->wrapWithParentTestGroups($new_group);
-    else
-      return $new_group;
-  }
-
-  function createTestGroupWithParents()
-  {
-    $group = $this->createTestGroup();
-
-    if($parent = $this->getParent())
-    {
-      $final_group = new TestSuite($group->getLabel());
-      $wrapped = $parent->wrapWithParentTestGroups($group);
-      $final_group->addTestCase($wrapped);
-      return $final_group;
-    }
-    else
-      return $group;
-  }
 }
 
 ?>

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestTreePath.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTreePath.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTreePath.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -1,20 +1,64 @@
 <?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com 
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
- */
-
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
 /**
  * class lmbTestTreePath.
  *
  * @package tests_runner
  * @version $Id$
- */
+ */
 class lmbTestTreePath
 {
+  protected $nodes = array();
+
+  function addNode($node)
+  {
+    $this->nodes[] = $node;
+  }
+
+  function createTestGroup()
+  {
+    if($node = end($this->nodes))
+      return $node->createTestGroup();
+  }
+
+  function init()
+  {
+    foreach($this->nodes as $node)
+      $node->init();
+  }
+
+  function hasSkippedNodes()
+  {
+    return $this->getSkippedNode() !== null;
+  }
+
+  function getSkippedNode()
+  {
+    foreach($this->nodes as $node)
+    {
+      if($node->isSkipped())
+        return $node;
+    }
+  }
+
+  function size()
+  {
+    return count($this->nodes);
+  }
+
+  function at($index)
+  {
+    if(isset($this->nodes[$index]))
+      return $this->nodes[$index];
+  }
+
   static function normalize($tests_path)
   {
     return '/' . implode('/', self :: toArray($tests_path));

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestTreeTerminalNode.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTreeTerminalNode.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTreeTerminalNode.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -13,17 +13,12 @@
  * @package tests_runner
  * @version $Id$
  */
-abstract class lmbTestTreeTerminalNode extends lmbTestTreeNode
+class lmbTestTreeTerminalNode extends lmbTestTreeNode
 {
   function addChild($node){}
 
   function findChildByPath($path){}
 
-  function createTestGroupWithoutChildren()
-  {
-    return $this->createTestGroup();
-  }
-
   function isTerminal()
   {
     return true;

Modified: 3.x/trunk/limb/tests_runner/src/lmbTestWebUI.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestWebUI.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestWebUI.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -1,21 +1,20 @@
 <?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com 
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
-require_once(dirname(__FILE__) . '/lmbTestTree.class.php');
 require_once(dirname(__FILE__) . '/lmbTestTreePath.class.php');
-require_once(dirname(__FILE__) . '/lmbTestHTMLReporter.class.php');
-
+require_once(dirname(__FILE__) . '/lmbTestHTMLReporter.class.php');
+
 /**
  * class lmbTestWebUI.
  *
  * @package tests_runner
  * @version $Id$
- */
+ */
 class lmbTestWebUI
 {
   protected $tree;
@@ -23,7 +22,7 @@
 
   function __construct($root_node)
   {
-    $this->tree = new lmbTestTree($root_node);
+    $this->root_node = $root_node;
   }
 
   function setEncoding($encoding)
@@ -61,25 +60,26 @@
 
   function perform($path)
   {
-    $this->tree->perform($path, $this->_getReporter());
+    $runner = new lmbTestRunner();
+    $runner->setReporter($this->_getReporter());
+    $runner->run($this->root_node, $path);
 
     if(isset($_GET['back']))
       $postfix = '';
     else
       $postfix = '/..';
 
-    echo '<small>' . $this->tree->getElapsedTime() . '</small>';
+    echo '<small>' . $runner->getRunTime() . '</small>';
     echo '<p>' . $this->_createBrowseLink($path . $postfix, 'Back') . '</p>';
   }
 
   function browse($path='/')
   {
-    $root_node = $this->tree->find('/');
-    $node = $this->tree->find($path);
+    $node = $this->root_node->findChildByPath($path);
 
     echo '<html><body><style>@import url("style.css");</style>';
 
-    if($root_node !== $node)
+    if($this->root_node !== $node)
       echo '<p>' . $this->_createBrowseLink($path . '/..', 'Back');
 
     $sub_nodes = $node->getChildren();

Added: 3.x/trunk/limb/tests_runner/tests/cases/lmbTestFileRunnerTest.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/tests/cases/lmbTestFileRunnerTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/tests_runner/tests/cases/lmbTestFileRunnerTest.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -0,0 +1,106 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http:/limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http:/bit-creative.com)
+ * @license    LGPL http:/www.gnu.org/copyleft/lesser.html
+ */
+require_once(dirname(__FILE__) . '/../common.inc.php');
+require_once(dirname(__FILE__) . '/../../src/lmbTestFileRunner.class.php');
+
+class lmbTestFileRunnerTest extends lmbTestRunnerBase
+{
+  protected $cases;
+
+  function setUp()
+  {
+    $this->_rmdir(LIMB_VAR_DIR);
+    mkdir(LIMB_VAR_DIR);
+    //we need unique temporary dir since test modules are included once
+    mkdir($this->cases = LIMB_VAR_DIR . '/' . mt_rand());
+  }
+
+  function tearDown()
+  {
+    $this->_rmdir(LIMB_VAR_DIR);
+  }
+
+  function testRunOkForFile()
+  {
+    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
+    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
+    $zoo = $this->_createTestCase($this->cases . '/a/z/zoo_test.php');
+
+    $runner = new lmbTestFileRunner();
+    ob_start();
+    $this->assertTrue($runner->runForFiles($this->cases . '/a/z/zoo_test.php'));
+    ob_end_clean();
+    $this->assertTrue($runner->testsFound());
+  }
+
+  function testRunOkForDir()
+  {
+    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
+    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
+    $zoo = $this->_createTestCase($this->cases . '/a/z/zoo_test.php');
+
+    $runner = new lmbTestFileRunner();
+    ob_start();
+    $this->assertTrue($runner->runForFiles($this->cases . '/a'));
+    ob_end_clean();
+    $this->assertTrue($runner->testsFound());
+  }
+
+  function testNoRunnableFilesFound()
+  {
+    $runner = new lmbTestFileRunner();
+    $this->assertTrue($runner->runForFiles($this->cases . mt_rand()));
+    $this->assertFalse($runner->testsFound());
+  }
+
+  function testRunFailedForFile()
+  {
+    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
+    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
+    $zoo = $this->_createTestCaseFailing($this->cases . '/a/z/zoo_test.php');
+
+    $runner = new lmbTestFileRunner();
+    ob_start();
+    $this->assertFalse($runner->runForFiles($this->cases . '/a/z/zoo_test.php'));
+    ob_end_clean();
+    $this->assertTrue($runner->testsFound());
+  }
+
+  function testRunFailedForDir()
+  {
+    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
+    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
+    $zoo = $this->_createTestCaseFailing($this->cases . '/a/z/zoo_test.php');
+
+    $runner = new lmbTestFileRunner();
+    ob_start();
+    $this->assertFalse($runner->runForFiles($this->cases . '/a'));
+    ob_end_clean();
+    $this->assertTrue($runner->testsFound());
+  }
+
+  function testTestsInSkippedDirAreNotExecuted()
+  {
+    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
+    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
+    $zoo = $this->_createTestCase($this->cases . '/a/z/zoo_test.php');
+
+    file_put_contents($this->cases . '/a/.skipif.php', '<?php return true; ?>');
+
+    $runner = new lmbTestFileRunner();
+    ob_start();
+    $this->assertTrue($runner->runForFiles($this->cases . '/a/z/zoo_test.php'));
+    $str = ob_get_contents();
+    ob_end_clean();
+    $this->assertTrue($runner->testsFound());
+    $this->assertNoPattern('~' . preg_quote($zoo->getOutput()) . '~', $str);
+  }
+}
+
+?>

Deleted: 3.x/trunk/limb/tests_runner/tests/cases/lmbTestRunnerTest.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/tests/cases/lmbTestRunnerTest.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/tests/cases/lmbTestRunnerTest.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -1,89 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http:/limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http:/bit-creative.com)
- * @license    LGPL http:/www.gnu.org/copyleft/lesser.html
- */
-require_once(dirname(__FILE__) . '/../common.inc.php');
-require_once(dirname(__FILE__) . '/../../src/lmbTestRunner.class.php');
-
-class lmbTestRunnerTest extends lmbTestRunnerBase
-{
-  protected $cases;
-
-  function setUp()
-  {
-    $this->_rmdir(LIMB_VAR_DIR);
-    mkdir(LIMB_VAR_DIR);
-    //we need unique temporary dir since test modules are included once
-    mkdir($this->cases = LIMB_VAR_DIR . '/' . mt_rand());
-  }
-
-  function tearDown()
-  {
-    $this->_rmdir(LIMB_VAR_DIR);
-  }
-
-  function testRunOkForFile()
-  {
-    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
-    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
-    $zoo = $this->_createTestCase($this->cases . '/a/z/zoo_test.php');
-
-    $runner = new lmbTestRunner($this->cases . '/a/z/zoo_test.php');
-    ob_start();
-    $this->assertTrue($runner->run($found));
-    ob_end_clean();
-    $this->assertTrue($found);
-  }
-
-  function testRunOkForDir()
-  {
-    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
-    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
-    $zoo = $this->_createTestCase($this->cases . '/a/z/zoo_test.php');
-
-    $runner = new lmbTestRunner($this->cases . '/a');
-    ob_start();
-    $this->assertTrue($runner->run($found));
-    ob_end_clean();
-    $this->assertTrue($found);
-  }
-
-  function testNoRunnableFilesFound()
-  {
-    $runner = new lmbTestRunner($this->cases . mt_rand());
-    $this->assertTrue($runner->run($found));
-    $this->assertFalse($found);
-  }
-
-  function testRunFailedForFile()
-  {
-    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
-    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
-    $zoo = $this->_createTestCaseFailing($this->cases . '/a/z/zoo_test.php');
-
-    $runner = new lmbTestRunner($this->cases . '/a/z/zoo_test.php');
-    ob_start();
-    $this->assertFalse($runner->run($found));
-    ob_end_clean();
-    $this->assertTrue($found);
-  }
-
-  function testRunFailedForDir()
-  {
-    $foo = $this->_createTestCase($this->cases . '/foo_test.php');
-    $bar = $this->_createTestCase($this->cases . '/a/bar_test.php');
-    $zoo = $this->_createTestCaseFailing($this->cases . '/a/z/zoo_test.php');
-
-    $runner = new lmbTestRunner($this->cases . '/a');
-    ob_start();
-    $this->assertFalse($runner->run($found));
-    ob_end_clean();
-    $this->assertTrue($found);
-  }
-}
-
-?>

Modified: 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeDirNodeTest.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeDirNodeTest.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeDirNodeTest.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -191,99 +191,6 @@
     $this->assertEqual($str, "wow" . $test1->getOutput() . $test2->getOutput() . "hey");
   }
 
-  function testCreateTestGroupWithParentsForTerminalNode()
-  {
-    mkdir($this->var_dir . '/a');
-    mkdir($this->var_dir . '/a/b');
-
-    $test1 = new GeneratedTestClass();
-    $test2 = new GeneratedTestClass();
-
-    file_put_contents($this->var_dir . '/a/.setup.php', '<?php echo "wow"; ?>');
-    file_put_contents($this->var_dir . '/a/.teardown.php', '<?php echo "hey"; ?>');
-
-    file_put_contents($this->var_dir . '/a/b/bar_test.php', $test1->generate());
-    file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate());
-
-    $root_node = new lmbTestTreeDirNode($this->var_dir);
-    $terminal_node = $root_node->findChildByPath('/0/0/1');
-
-    //we check for any possible garbage during php includes
-    ob_start();
-    $group = $terminal_node->createTestGroupWithParents();
-
-    $group->run(new SimpleReporter());
-    $str = ob_get_contents();
-    ob_end_clean();
-    $this->assertEqual($str, "wow" . $test2->getOutput() . "hey");
-  }
-
-  function testCreateTestGroupWithParentsForTopLevelTerminalNode()
-  {
-    mkdir($this->var_dir . '/a');
-
-    $test = new GeneratedTestClass();
-
-    file_put_contents($this->var_dir . '/a/.setup.php', '<?php echo "wow"; ?>');
-    file_put_contents($this->var_dir . '/a/.teardown.php', '<?php echo "hey"; ?>');
-
-    file_put_contents($this->var_dir . '/a/bar_test.php', $test->generate());
-
-    $root_node = new lmbTestTreeDirNode($this->var_dir . '/a');
-    $terminal_node = $root_node->findChildByPath('/0');
-
-    //we check for any possible garbage during php includes
-    ob_start();
-    $group = $terminal_node->createTestGroupWithParents();
-
-    $group->run(new SimpleReporter());
-    $str = ob_get_contents();
-    ob_end_clean();
-    $this->assertEqual($str, "wow" . $test->getOutput() . "hey");
-  }
-
-  function testCreateTestGroupWithParents()
-  {
-    mkdir($this->var_dir . '/a');
-    mkdir($this->var_dir . '/a/b');
-
-    $test1 = new GeneratedTestClass();
-    $test2 = new GeneratedTestClass();
-
-    $skipped_test1 = new GeneratedTestClass();
-    $skipped_test2 = new GeneratedTestClass();
-
-    file_put_contents($this->var_dir . '/a/.setup.php', '<?php echo "|wow_start|"; ?>');
-    file_put_contents($this->var_dir . '/a/.teardown.php', '<?php echo "|wow_end|"; ?>');
-
-    file_put_contents($this->var_dir . '/a/skipped1_test.php', $skipped_test1->generate());
-    file_put_contents($this->var_dir . '/a/skipped2_test.php', $skipped_test2->generate());
-
-    file_put_contents($this->var_dir . '/a/b/.setup.php', '<?php echo "|hey_start|"; ?>');
-    file_put_contents($this->var_dir . '/a/b/.teardown.php', '<?php echo "|hey_end|"; ?>');
-
-    file_put_contents($this->var_dir . '/a/b/bar_test.php', $test1->generate());
-    file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate());
-
-    $root_node = new lmbTestTreeDirNode($this->var_dir);
-
-    $b_node = $root_node->findChildByPath('/0/0');
-    $this->assertFalse($b_node->isTerminal());
-    $this->assertEqual($b_node->getDir(), $this->var_dir . '/a/b');
-
-    //we check for any possible garbage during php includes
-    ob_start();
-    $group = $b_node->createTestGroupWithParents();
-
-    $group->run(new SimpleReporter());
-    $str = ob_get_contents();
-    ob_end_clean();
-    $this->assertEqual($str, "|wow_start|" . "|hey_start|" .
-                             $test1->getOutput() . $test2->getOutput() .
-                             "|hey_end|" . "|wow_end|");
-
-  }
-
   function testUseExternalTestLabel()
   {
     file_put_contents($this->var_dir . '/.description', 'Foo');
@@ -302,86 +209,53 @@
     $this->assertEqual($group->getLabel(), 'Group test in "' . $this->var_dir . '"');
   }
 
-  function testBootstrap()
+  function testInit()
   {
     file_put_contents($this->var_dir . '/.init.php', '<?php echo "hey!"; ?>');
 
     $node = new lmbTestTreeDirNode($this->var_dir);
     ob_start();
-    $group = $node->bootstrap();
+    $group = $node->init();
     $str = ob_get_contents();
     ob_end_clean();
     $this->assertEqual($str, "hey!");
   }
 
-  function testBootstrapPath()
+  function testSkipTestsDirectory()
   {
     mkdir($this->var_dir . '/a');
     mkdir($this->var_dir . '/a/b');
 
     $test1 = new GeneratedTestClass();
+    $test2 = new GeneratedTestClass();
 
-    file_put_contents($this->var_dir . '/a/.init.php', '<?php echo "wow"; ?>');
+    file_put_contents($this->var_dir . '/a/bar_test.php', $test1->generate());
+    file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate());
 
-    file_put_contents($this->var_dir . '/a/b/bar_test.php', $test1->generate());
+    file_put_contents($this->var_dir . '/a/b/.skipif.php', '<?php return true; ?>');
 
     $root_node = new lmbTestTreeDirNode($this->var_dir);
+    $group = $root_node->createTestGroup();
 
     ob_start();
-    $root_node->bootstrapPath('/0/0/0');
-    $str = ob_get_contents();
-    ob_end_clean();
-    $this->assertEqual($str, "wow");
-
-    $terminal_node = $root_node->findChildByPath('/0/0/0');
-
-    ob_start();
-    //we check for any possible garbage during php includes
-    $group = $terminal_node->createTestGroupWithParents();
-
     $group->run(new SimpleReporter());
     $str = ob_get_contents();
     ob_end_clean();
     $this->assertEqual($str, $test1->getOutput());
   }
 
-  function testBootstrapForChildDirectories()
+  function testDontSkipTestsDirectory()
   {
     mkdir($this->var_dir . '/a');
     mkdir($this->var_dir . '/a/b');
-    mkdir($this->var_dir . '/a/c');
 
     $test1 = new GeneratedTestClass();
-
-    file_put_contents($this->var_dir . '/a/b/bar_test.php', $test1->generate());
-    file_put_contents($this->var_dir . '/a/c/.init.php', '<?php echo "wow"; ?>');
-
-    $root_node = new lmbTestTreeDirNode($this->var_dir);
-
-    $node = $root_node->findChildByPath('/0');
-
-    ob_start();
-    //we check for any possible garbage during php includes
-    $group = $node->createTestGroupWithParents();
-
-    $group->run(new SimpleReporter());
-    $str = ob_get_contents();
-    ob_end_clean();
-    $this->assertEqual($str, 'wow' . $test1->getOutput());
-  }
-
-  function testSkipTestsDirectory()
-  {
-    mkdir($this->var_dir . '/a');
-    mkdir($this->var_dir . '/a/b');
-
-    $test1 = new GeneratedTestClass();
     $test2 = new GeneratedTestClass();
 
     file_put_contents($this->var_dir . '/a/bar_test.php', $test1->generate());
     file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate());
 
-    file_put_contents($this->var_dir . '/a/b/.skipif.php', '<?php return true; ?>');
+    file_put_contents($this->var_dir . '/a/b/.skipif.php', '<?php return false; ?>');
 
     $root_node = new lmbTestTreeDirNode($this->var_dir);
     $group = $root_node->createTestGroup();
@@ -390,10 +264,10 @@
     $group->run(new SimpleReporter());
     $str = ob_get_contents();
     ob_end_clean();
-    $this->assertEqual($str, $test1->getOutput());
+    $this->assertEqual($str, $test2->getOutput() . $test1->getOutput());
   }
 
-  function testDontSkipTestsDirectory()
+  function testInitDoesntHappenIfDirIsSkipped()
   {
     mkdir($this->var_dir . '/a');
     mkdir($this->var_dir . '/a/b');
@@ -404,7 +278,8 @@
     file_put_contents($this->var_dir . '/a/bar_test.php', $test1->generate());
     file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate());
 
-    file_put_contents($this->var_dir . '/a/b/.skipif.php', '<?php return false; ?>');
+    file_put_contents($this->var_dir . '/a/b/.init.php', '<?php echo "wow" ?>');
+    file_put_contents($this->var_dir . '/a/b/.skipif.php', '<?php return true; ?>');
 
     $root_node = new lmbTestTreeDirNode($this->var_dir);
     $group = $root_node->createTestGroup();
@@ -413,7 +288,7 @@
     $group->run(new SimpleReporter());
     $str = ob_get_contents();
     ob_end_clean();
-    $this->assertEqual($str, $test2->getOutput() . $test1->getOutput());
+    $this->assertEqual($str, $test1->getOutput());
   }
 
   function testSkippedDirFixtureSkippedToo()
@@ -435,30 +310,6 @@
     ob_end_clean();
     $this->assertEqual($str, '');
   }
-
-  function testBootstrappingDoesntHappenIfDirIsSkipped()
-  {
-    mkdir($this->var_dir . '/a');
-    mkdir($this->var_dir . '/a/b');
-
-    $test1 = new GeneratedTestClass();
-    $test2 = new GeneratedTestClass();
-
-    file_put_contents($this->var_dir . '/a/bar_test.php', $test1->generate());
-    file_put_contents($this->var_dir . '/a/b/foo_test.php', $test2->generate());
-
-    file_put_contents($this->var_dir . '/a/b/.init.php', '<?php echo "wow" ?>');
-    file_put_contents($this->var_dir . '/a/b/.skipif.php', '<?php return true; ?>');
-
-    $root_node = new lmbTestTreeDirNode($this->var_dir);
-    $group = $root_node->createTestGroup();
-
-    ob_start();
-    $group->run(new SimpleReporter());
-    $str = ob_get_contents();
-    ob_end_clean();
-    $this->assertEqual($str, $test1->getOutput());
-  }
 }
 
 ?>

Added: 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeNodeTest.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeNodeTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeNodeTest.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -0,0 +1,77 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+require_once(dirname(__FILE__) . '/../common.inc.php');
+require_once(dirname(__FILE__) . '/../../src/lmbTestTreeNode.class.php');
+
+class lmbTestTreeNodeTest extends lmbTestRunnerBase
+{
+  function testAddChildren()
+  {
+    $a = new lmbTestTreeNode();
+    $a_b = new lmbTestTreeNode();
+
+    $root = new lmbTestTreeNode();
+    $root->addChild($a);
+    $a->addChild($a_b);
+
+    $this->assertNull($root->getParent());
+    $this->assertTrue($a->getParent() === $root);
+    $this->assertTrue($a_b->getParent() === $a);
+  }
+
+  function testFindChildByPath()
+  {
+    $a = new lmbTestTreeNode();
+    $a_b = new lmbTestTreeNode();
+    $c = new lmbTestTreeNode();
+
+    $root = new lmbTestTreeNode();
+    $root->addChild($a);
+    $a->addChild($a_b);
+    $root->addChild($c);
+
+    $this->assertTrue($root->findChildByPath('/') === $root);
+    $this->assertTrue($root->findChildByPath('/0') === $a);
+    $this->assertTrue($root->findChildByPath('/0/0') === $a_b);
+    $this->assertTrue($root->findChildByPath('/1') === $c);
+    $this->assertNull($root->findChildByPath('/100'));
+
+    $this->assertTrue($a->findChildByPath('/0') === $a_b);
+    $this->assertNull($a->findChildByPath('/100'));
+  }
+
+  function testObjectifyPath()
+  {
+    $a = new lmbTestTreeNode();
+    $a_b = new lmbTestTreeNode();
+    $c = new lmbTestTreeNode();
+
+    $root = new lmbTestTreeNode();
+    $root->addChild($a);
+    $a->addChild($a_b);
+    $root->addChild($c);
+
+    $path = $root->objectifyPath('/0/0');
+    $this->assertEqual($path->size(), 3);
+    $this->assertTrue($path->at(0) === $root);
+    $this->assertTrue($path->at(1) === $a);
+    $this->assertTrue($path->at(2) === $a_b);
+    $this->assertNull($path->at(3));
+
+    $path = $root->objectifyPath('/1');
+    $this->assertEqual($path->size(), 2);
+    $this->assertTrue($path->at(0) === $root);
+    $this->assertTrue($path->at(1) === $c);
+    $this->assertNull($path->at(2));
+
+    $this->assertNull($root->objectifyPath('/100'));
+  }
+}
+
+?>

Deleted: 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeTest.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeTest.class.php	2007-06-27 14:29:40 UTC (rev 6019)
+++ 3.x/trunk/limb/tests_runner/tests/cases/lmbTestTreeTest.class.php	2007-06-27 15:12:32 UTC (rev 6020)
@@ -1,57 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html
- */
-require_once(dirname(__FILE__) . '/../../src/lmbTestTree.class.php');
-require_once(dirname(__FILE__) . '/../../src/lmbTestTreeDirNode.class.php');
-require_once(dirname(__FILE__) . '/../../src/lmbTestGroup.class.php');
-
-Mock :: generate('lmbTestTreeDirNode', 'MockTestTreeNode');
-
-class lmbTestTreeTest extends UnitTestCase
-{
-  function setUp()
-  {
-    Mock :: generate('lmbTestGroup', 'MockTestGroup');//prevent this mock to be executed as a test case
-  }
-
-  function testPerform()
-  {
-    $node = new MockTestTreeNode();
-
-    $root_node = new MockTestTreeNode();
-    $root_node->expectOnce('findChildByPath', array($path = '/1/0'));
-    $root_node->expectOnce('bootstrapPath', array($path));
-    $root_node->setReturnValue('findChildByPath', $node);
-
-    $group = new MockTestGroup();
-
-    $node->expectOnce('createTestGroupWithParents');
-    $node->setReturnValue('createTestGroupWithParents', $group);
-
-    $group->expectOnce('run', array($reporter = new SimpleReporter()));
-    $group->setReturnValue('run', $res = 1);
-
-    $runner = new lmbTestTree($root_node);
-
-    $this->assertEqual($runner->perform($path, $reporter), $res);
-  }
-
-  function testFind()
-  {
-    $node = new MockTestTreeNode();
-    $node->expectOnce('findChildByPath', array($path = '/1/0'));
-    $node->setReturnValue('findChildByPath', $node);
-
-    $runner = new lmbTestTree($node);
-
-    //preventing "Nesting level too deep - recursive dependency?"
-    $this->assertTrue($runner->find($path) === $node);
-  }
-}
-
-?>



More information about the limb-svn mailing list