[limb-svn] r6222 - in 3.x/trunk/limb/fs: src tests/cases

svn at limb-project.com svn at limb-project.com
Tue Aug 7 17:28:59 MSD 2007


Author: pachanga
Date: 2007-08-07 17:28:59 +0400 (Tue, 07 Aug 2007)
New Revision: 6222
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6222

Modified:
   3.x/trunk/limb/fs/src/lmbFsRecursiveIterator.class.php
   3.x/trunk/limb/fs/tests/cases/lmbFsRecursiveIteratorTest.class.php
   3.x/trunk/limb/fs/tests/cases/lmbFsTest.class.php
Log:
-- simplifying tests a bit
-- lmbFsRecursiveIterator :: getPathName() is deprecated now, use getPath() instead



Modified: 3.x/trunk/limb/fs/src/lmbFsRecursiveIterator.class.php
===================================================================
--- 3.x/trunk/limb/fs/src/lmbFsRecursiveIterator.class.php	2007-08-07 07:24:35 UTC (rev 6221)
+++ 3.x/trunk/limb/fs/src/lmbFsRecursiveIterator.class.php	2007-08-07 13:28:59 UTC (rev 6222)
@@ -1,155 +1,163 @@
-<?php
+<?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 
- */
+ */
 lmb_require('limb/fs/src/exception/lmbFsException.class.php');
 
-/**
- * class lmbFsRecursiveIterator.
- *
- * @package fs
- * @version $Id$
+/**
+ * class lmbFsRecursiveIterator.
+ *
+ * @package fs
+ * @version $Id$
  */
-class lmbFsRecursiveIterator
-{
-  protected $start_dir;
-  protected $open_dirs = array();
-  protected $look_ahead_buffer;
-  protected $valid;
-  protected $dir;
-  protected $item;
-
-  function __construct($dir)
-  {
-    $this->start_dir = $dir;
-  }
-
-  function rewind()
-  {
-    $this->open_dirs = array();
-    $this->look_ahead_buffer = null;
-    $this->valid = true;
-    $this->_openDir($this->start_dir);
-
-    $this->next();
-  }
-
-  protected function _openDir($dir)
-  {
-    $dir = rtrim($dir, '/') . '/';
-    if(($h = @opendir($dir)) === false)
-      throw new lmbFsException('can not open directory for scanning', array('dir' => $dir));
-
-    $this->open_dirs[] = array('handle' => $h, 'dir' => $dir);
-  }
-
-  protected function _openDirIfNeccessary()
-  {
-    if(!$this->isDot() && $this->isDir())
-      $this->_openDir($this->getPathName());
-  }
-
-  protected function _closeTerminalDirs()
-  {
-    if(!$this->_readItem() && $this->_hasOpenDirs())
-    {
-      $h = $this->_getLastOpenDirHandle();
-      closedir($h);
-      array_pop($this->open_dirs);
-      $this->_closeTerminalDirs();
-    }
-  }
-
-  protected function _hasOpenDirs()
-  {
-    return sizeof($this->open_dirs) > 0;
-  }
-
-  protected function _getLastOpenDirHandle()
-  {
-    $index = sizeof($this->open_dirs) - 1;
-    if(isset($this->open_dirs[$index]))
-      return $this->open_dirs[$index]['handle'];
-  }
-
-  protected function _getLastOpenDir()
-  {
-    $index = sizeof($this->open_dirs) - 1;
-    if(isset($this->open_dirs[$index]))
-      return $this->open_dirs[$index]['dir'];
-  }
-
-  protected function _readItem()
-  {
-    if(!$handle = $this->_getLastOpenDirHandle())
-      return false;
-
-    $this->dir = $this->_getLastOpenDir();
-
-    $this->item = readdir($handle);
-
-    if($this->item !== false)
-      $this->_openDirIfNeccessary();
-
-    return $this->item;
-  }
-
-  function current()
-  {
-    return $this;//???
-  }
-
-  function valid()
-  {
-    return $this->valid;
-  }
-
-  function next()
-  {
-    $this->valid = true;
-
-    if($this->_readItem() === false)
-    {
-      $this->_closeTerminalDirs();
-
-      if(!$this->_hasOpenDirs())
-        $this->valid = false;
-    }
-  }
-
-  function isDot()
-  {
-    return ($this->item == '.' || $this->item == '..');
-  }
-
-  function isDir()
-  {
-    return is_dir($this->getPathName());
-  }
-
-  function isFile()
-  {
-    return is_file($this->getPathName()) && !is_dir($this->getPathName());
-  }
-
-  function getPathName()
-  {
-    return $this->dir . $this->item;
-  }
-
-  function getCurrentDirectoryName()
-  {
-    return $this->dir;
-  }
-
-  function getCurrentFileName()
-  {
-    return $this->item;
-  }
-}
-
-
+class lmbFsRecursiveIterator
+{
+  protected $start_dir;
+  protected $open_dirs = array();
+  protected $look_ahead_buffer;
+  protected $valid;
+  protected $dir;
+  protected $item;
+
+  function __construct($dir)
+  {
+    $this->start_dir = $dir;
+  }
+
+  function rewind()
+  {
+    $this->open_dirs = array();
+    $this->look_ahead_buffer = null;
+    $this->valid = true;
+    $this->_openDir($this->start_dir);
+
+    $this->next();
+  }
+
+  protected function _openDir($dir)
+  {
+    $dir = rtrim($dir, '/') . '/';
+    if(($h = @opendir($dir)) === false)
+      throw new lmbFsException('can not open directory for scanning', array('dir' => $dir));
+
+    $this->open_dirs[] = array('handle' => $h, 'dir' => $dir);
+  }
+
+  protected function _openDirIfNeccessary()
+  {
+    if(!$this->isDot() && $this->isDir())
+      $this->_openDir($this->getPath());
+  }
+
+  protected function _closeTerminalDirs()
+  {
+    if(!$this->_readItem() && $this->_hasOpenDirs())
+    {
+      $h = $this->_getLastOpenDirHandle();
+      closedir($h);
+      array_pop($this->open_dirs);
+      $this->_closeTerminalDirs();
+    }
+  }
+
+  protected function _hasOpenDirs()
+  {
+    return sizeof($this->open_dirs) > 0;
+  }
+
+  protected function _getLastOpenDirHandle()
+  {
+    $index = sizeof($this->open_dirs) - 1;
+    if(isset($this->open_dirs[$index]))
+      return $this->open_dirs[$index]['handle'];
+  }
+
+  protected function _getLastOpenDir()
+  {
+    $index = sizeof($this->open_dirs) - 1;
+    if(isset($this->open_dirs[$index]))
+      return $this->open_dirs[$index]['dir'];
+  }
+
+  protected function _readItem()
+  {
+    if(!$handle = $this->_getLastOpenDirHandle())
+      return false;
+
+    $this->dir = $this->_getLastOpenDir();
+
+    $this->item = readdir($handle);
+
+    if($this->item !== false)
+      $this->_openDirIfNeccessary();
+
+    return $this->item;
+  }
+
+  function current()
+  {
+    return $this;//???
+  }
+
+  function valid()
+  {
+    return $this->valid;
+  }
+
+  function next()
+  {
+    $this->valid = true;
+
+    if($this->_readItem() === false)
+    {
+      $this->_closeTerminalDirs();
+
+      if(!$this->_hasOpenDirs())
+        $this->valid = false;
+    }
+  }
+
+  function isDot()
+  {
+    return ($this->item == '.' || $this->item == '..');
+  }
+
+  function isDir()
+  {
+    return is_dir($this->getPath());
+  }
+
+  function isFile()
+  {
+    return is_file($this->getPath()) && !is_dir($this->getPath());
+  }
+
+  function getPath()
+  {
+    return $this->dir . $this->item;
+  }
+
+  /**
+   * @deprecated
+   */
+  function getPathName()
+  {
+    return $this->getPath();
+  }
+
+  function getCurrentDirectoryName()
+  {
+    return $this->dir;
+  }
+
+  function getCurrentFileName()
+  {
+    return $this->item;
+  }
+}
+
+

Modified: 3.x/trunk/limb/fs/tests/cases/lmbFsRecursiveIteratorTest.class.php
===================================================================
--- 3.x/trunk/limb/fs/tests/cases/lmbFsRecursiveIteratorTest.class.php	2007-08-07 07:24:35 UTC (rev 6221)
+++ 3.x/trunk/limb/fs/tests/cases/lmbFsRecursiveIteratorTest.class.php	2007-08-07 13:28:59 UTC (rev 6222)
@@ -1,241 +1,158 @@
-<?php
+<?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 
- */
-lmb_require('limb/fs/src/lmbFsRecursiveIterator.class.php');
-lmb_require('limb/fs/src/lmbFs.class.php');
-
-class lmbFsRecursiveIteratorTest extends UnitTestCase
-{
-  var $dir;
-
-  function lmbFsRecursiveIteratorTest()
-  {
-    $this->dir = LIMB_VAR_DIR . '/tmp/';
-    parent :: UnitTestCase();
-  }
-
-  function _createFileSystem()
-  {
-    lmbFs :: mkdir($this->dir);
-    touch($this->dir . '/a');
-
-    lmbFs :: mkdir($this->dir . '/nested/.sub-nested/');
-    touch($this->dir . '/nested/.sub-nested/d');
-
-    lmbFs :: mkdir($this->dir . '/nested/b');
-    touch($this->dir . '/nested/c');
-  }
-
-  function _removeFileSystem()
-  {
-    lmbFs :: rm($this->dir);
-  }
-
-  function testExceptionIterate()
-  {
-    $it = new lmbFsRecursiveIterator('no-such-a-dir');
-
-    try
-    {
-      $it->rewind();
-      $this->assertTrue(false);
-    }
-    catch(lmbFsException $e){}
-  }
-
-  function testSimpleIterate()
-  {
-    lmbFs :: rm($this->dir);
-    lmbFs :: mkdir($this->dir);
-
-    $it = new lmbFsRecursiveIterator($this->dir);
-
-    $it->rewind();
-    $this->_assertDotDir($it, $this->dir . '/.', __LINE__);
-
-    $it->next();
-    $this->_assertDotDir($it, $this->dir . '/..', __LINE__);
-
-    $it->next();
-    $this->assertFalse($it->valid());
-
-    lmbFs :: rm($this->dir);
-  }
-
-  function testComplexIterate()
-  {
-    $this->_removeFileSystem();
-    $this->_createFileSystem();
-
-    $it = new lmbFsRecursiveIterator($this->dir);
-
-    $it->rewind();
-    $this->_assertDotDir($it, $this->dir . '/.', __LINE__);
-
-    $it->next();
-    $this->_assertDotDir($it, $this->dir . '/..', __LINE__);
-
-    $it->next();
-    $this->_assertFile($it, $this->dir . '/a', __LINE__);
-
-    $it->next();
-    $this->_assertDir($it, $this->dir . '/nested', __LINE__);
-
-    $it->next();
-    $this->_assertDotDir($it, $this->dir . '/nested/.', __LINE__);
-
-    $it->next();
-    $this->_assertDotDir($it, $this->dir . '/nested/..', __LINE__);
-
-    if(lmbSys :: isWin32())
-    {
-      $it->next();
-      $this->_assertDir($it, $this->dir . '/nested/.sub-nested', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/.sub-nested/.', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/.sub-nested/..', __LINE__);
-
-      $it->next();
-      $this->_assertFile($it, $this->dir . '/nested/.sub-nested/d', __LINE__);
-
-      $it->next();
-      $this->_assertDir($it, $this->dir . '/nested/b', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/b/.', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/b/..', __LINE__);
-
-      $it->next();
-      $this->_assertFile($it, $this->dir . '/nested/c', __LINE__);
-    }
-    else
-    {
-      $it->next();
-      $this->_assertDir($it, $this->dir . '/nested/b', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/b/.', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/b/..', __LINE__);
-
-      $it->next();
-      $this->_assertFile($it, $this->dir . '/nested/c', __LINE__);
-
-      $it->next();
-      $this->_assertDir($it, $this->dir . '/nested/.sub-nested', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/.sub-nested/.', __LINE__);
-
-      $it->next();
-      $this->_assertDotDir($it, $this->dir . '/nested/.sub-nested/..', __LINE__);
-
-      $it->next();
-      $this->_assertFile($it, $this->dir . '/nested/.sub-nested/d', __LINE__);
-    }
-
-    $it->next();
-    $this->assertFalse($it->valid());
-
-    $this->_removeFileSystem();
-  }
-
-  function testLoop()
-  {
-    $this->_removeFileSystem();
-    $this->_createFileSystem();
-
-    $it = new lmbFsRecursiveIterator($this->dir);
-    $res = array();
-    for($it->rewind(); $it->valid(); $it->next())
-    {
-      $res[] = $it->getPathName();
-    }
-
-    $res = array_map(array('lmbFs', 'normalizePath'), $res);
-
-    if(lmbSys :: isWin32())
-    {
-      $this->assertEqual($res,
-                         array(lmbFs :: normalizePath($this->dir . '/.'),
-                               lmbFs :: normalizePath($this->dir . '/..'),
-                               lmbFs :: normalizePath($this->dir . '/a'),
-                               lmbFs :: normalizePath($this->dir . '/nested'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.'),
-                               lmbFs :: normalizePath($this->dir . '/nested/..'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/.'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/..'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/d'),
-                               lmbFs :: normalizePath($this->dir . '/nested/b'),
-                               lmbFs :: normalizePath($this->dir . '/nested/b/.'),
-                               lmbFs :: normalizePath($this->dir . '/nested/b/..'),
-                               lmbFs :: normalizePath($this->dir . '/nested/c'),
-                         ));
-    }
-    else
-    {
-      $this->assertEqual($res,
-                         array(lmbFs :: normalizePath($this->dir . '/.'),
-                               lmbFs :: normalizePath($this->dir . '/..'),
-                               lmbFs :: normalizePath($this->dir . '/a'),
-                               lmbFs :: normalizePath($this->dir . '/nested'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.'),
-                               lmbFs :: normalizePath($this->dir . '/nested/..'),
-                               lmbFs :: normalizePath($this->dir . '/nested/b'),
-                               lmbFs :: normalizePath($this->dir . '/nested/b/.'),
-                               lmbFs :: normalizePath($this->dir . '/nested/b/..'),
-                               lmbFs :: normalizePath($this->dir . '/nested/c'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/.'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/..'),
-                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/d'),
-                         ));
-    }
-
-    $this->_removeFileSystem();
-  }
-
-  function _assertDir($it, $path, $line='')
-  {
-    $this->assertTrue($it->valid(), '%s ' . $line);
-    $this->assertFalse($it->isDot(), '%s ' . $line);
-    $this->assertTrue($it->isDir(), '%s ' . $line);
-    $this->assertFalse($it->isFile(), '%s ' . $line);
-    $this->assertEqual(lmbFs :: normalizePath($it->getPathName()),
-                       lmbFs :: normalizePath($path), '%s ' . $line);
-  }
-
-  function _assertDotDir($it, $path, $line='')
-  {
-    $this->assertTrue($it->valid(), '%s ' . $line);
-    $this->assertTrue($it->isDot(), '%s ' . $line);
-    $this->assertTrue($it->isDir(), '%s ' . $line);
-    $this->assertFalse($it->isFile(), '%s ' . $line);
-    $this->assertEqual(lmbFs :: normalizePath($it->getPathName()),
-                       lmbFs :: normalizePath($path), '%s ' . $line);
-  }
-
-  function _assertFile($it, $path, $line='')
-  {
-    $this->assertTrue($it->valid(), '%s ' . $line);
-    $this->assertFalse($it->isDot(), '%s ' . $line);
-    $this->assertFalse($it->isDir(), '%s ' . $line);
-    $this->assertTrue($it->isFile(), '%s ' . $line);
-    $this->assertEqual(lmbFs :: normalizePath($it->getPathName()),
-                       lmbFs :: normalizePath($path), '%s ' . $line);
-  }
-}
-
+ */
+lmb_require('limb/fs/src/lmbFsRecursiveIterator.class.php');
+lmb_require('limb/fs/src/lmbFs.class.php');
 
+class lmbFsRecursiveIteratorTest extends UnitTestCase
+{
+  var $dir;
+
+  function lmbFsRecursiveIteratorTest()
+  {
+    $this->dir = LIMB_VAR_DIR . '/tmp/';
+    parent :: UnitTestCase();
+  }
+
+  function _createFileSystem()
+  {
+    lmbFs :: mkdir($this->dir);
+    touch($this->dir . '/a');
+
+    lmbFs :: mkdir($this->dir . '/nested/.sub-nested/');
+    touch($this->dir . '/nested/.sub-nested/d');
+
+    lmbFs :: mkdir($this->dir . '/nested/b');
+    touch($this->dir . '/nested/c');
+  }
+
+  function _removeFileSystem()
+  {
+    lmbFs :: rm($this->dir);
+  }
+
+  function testExceptionIterate()
+  {
+    $it = new lmbFsRecursiveIterator('no-such-a-dir');
+
+    try
+    {
+      $it->rewind();
+      $this->assertTrue(false);
+    }
+    catch(lmbFsException $e){}
+  }
+
+  function testSimpleIterate()
+  {
+    lmbFs :: rm($this->dir);
+    lmbFs :: mkdir($this->dir);
+
+    $it = new lmbFsRecursiveIterator($this->dir);
+
+    $it->rewind();
+    $this->_assertDotDir($it, $this->dir . '/.', __LINE__);
+
+    $it->next();
+    $this->_assertDotDir($it, $this->dir . '/..', __LINE__);
+
+    $it->next();
+    $this->assertFalse($it->valid());
+
+    lmbFs :: rm($this->dir);
+  }
+
+  function testComplexIterate()
+  {
+    $this->_removeFileSystem();
+    $this->_createFileSystem();
+
+    $it = new lmbFsRecursiveIterator($this->dir);
+    $res = array();
+    for($it->rewind(); $it->valid(); $it->next())
+    {
+      $res[] = $it->getPath();
+    }
+
+    var_dump($res);
+    $res = array_map(array('lmbFs', 'normalizePath'), $res);
+
+    if(lmbSys :: isWin32())
+    {
+      $this->assertEqual($res,
+                         array(lmbFs :: normalizePath($this->dir . '/.'),
+                               lmbFs :: normalizePath($this->dir . '/..'),
+                               lmbFs :: normalizePath($this->dir . '/a'),
+                               lmbFs :: normalizePath($this->dir . '/nested'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.'),
+                               lmbFs :: normalizePath($this->dir . '/nested/..'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/.'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/..'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/d'),
+                               lmbFs :: normalizePath($this->dir . '/nested/b'),
+                               lmbFs :: normalizePath($this->dir . '/nested/b/.'),
+                               lmbFs :: normalizePath($this->dir . '/nested/b/..'),
+                               lmbFs :: normalizePath($this->dir . '/nested/c'),
+                         ));
+    }
+    else
+    {
+      $this->assertEqual($res,
+                         array(lmbFs :: normalizePath($this->dir . '/.'),
+                               lmbFs :: normalizePath($this->dir . '/..'),
+                               lmbFs :: normalizePath($this->dir . '/a'),
+                               lmbFs :: normalizePath($this->dir . '/nested'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.'),
+                               lmbFs :: normalizePath($this->dir . '/nested/..'),
+                               lmbFs :: normalizePath($this->dir . '/nested/b'),
+                               lmbFs :: normalizePath($this->dir . '/nested/b/.'),
+                               lmbFs :: normalizePath($this->dir . '/nested/b/..'),
+                               lmbFs :: normalizePath($this->dir . '/nested/c'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/.'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/..'),
+                               lmbFs :: normalizePath($this->dir . '/nested/.sub-nested/d'),
+                         ));
+    }
+
+    $this->_removeFileSystem();
+  }
+
+  function _assertDir($it, $path, $line='')
+  {
+    $this->assertTrue($it->valid(), '%s ' . $line);
+    $this->assertFalse($it->isDot(), '%s ' . $line);
+    $this->assertTrue($it->isDir(), '%s ' . $line);
+    $this->assertFalse($it->isFile(), '%s ' . $line);
+    $this->assertEqual(lmbFs :: normalizePath($it->getPath()),
+                       lmbFs :: normalizePath($path), '%s ' . $line);
+  }
+
+  function _assertDotDir($it, $path, $line='')
+  {
+    $this->assertTrue($it->valid(), '%s ' . $line);
+    $this->assertTrue($it->isDot(), '%s ' . $line);
+    $this->assertTrue($it->isDir(), '%s ' . $line);
+    $this->assertFalse($it->isFile(), '%s ' . $line);
+    $this->assertEqual(lmbFs :: normalizePath($it->getPath()),
+                       lmbFs :: normalizePath($path), '%s ' . $line);
+  }
+
+  function _assertFile($it, $path, $line='')
+  {
+    $this->assertTrue($it->valid(), '%s ' . $line);
+    $this->assertFalse($it->isDot(), '%s ' . $line);
+    $this->assertFalse($it->isDir(), '%s ' . $line);
+    $this->assertTrue($it->isFile(), '%s ' . $line);
+    $this->assertEqual(lmbFs :: normalizePath($it->getPath()),
+                       lmbFs :: normalizePath($path), '%s ' . $line);
+  }
+}
+
+

Modified: 3.x/trunk/limb/fs/tests/cases/lmbFsTest.class.php
===================================================================
--- 3.x/trunk/limb/fs/tests/cases/lmbFsTest.class.php	2007-08-07 07:24:35 UTC (rev 6221)
+++ 3.x/trunk/limb/fs/tests/cases/lmbFsTest.class.php	2007-08-07 13:28:59 UTC (rev 6222)
@@ -1,519 +1,519 @@
-<?php
+<?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 
- */
-lmb_require('limb/fs/src/lmbFs.class.php');
-
-class SpecialDirWalker
-{
-  var $walked = array();
-  var $counter = 0;
-
-  function walk($dir, $file, $path, $params, &$return_params)
-  {
-    $this->walked[] = lmbFs :: normalizePath($path);
-    $return_params[] = $this->counter++;
-  }
-}
-
-class lmbFsTest extends UnitTestCase
-{
-  function _createFileSystem()
-  {
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/tmp/wow/hey/');
-
-    touch(LIMB_VAR_DIR . '/tmp/test1_1');
-    touch(LIMB_VAR_DIR . '/tmp/test1_2');
-    touch(LIMB_VAR_DIR . '/tmp/test1_3');
-
-    touch(LIMB_VAR_DIR . '/tmp/wow/test2_1');
-    touch(LIMB_VAR_DIR . '/tmp/wow/test2_2');
-    touch(LIMB_VAR_DIR . '/tmp/wow/test2_3');
-
-    touch(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1');
-    touch(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2');
-    touch(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3');
-  }
-
-  function _removeFileSystem()
-  {
-    $this->_rmdir(LIMB_VAR_DIR . '/tmp/');
-  }
-
-  function _rmdir($path)
-  {
-    if(!is_dir($path))
-      return;
-
-    $dir = opendir($path);
-    while($entry = readdir($dir))
-    {
-      if(is_file("$path/$entry"))
-        unlink("$path/$entry");
-      elseif(is_dir("$path/$entry") && $entry != '.' && $entry != '..')
-        $this->_rmdir("$path/$entry");
-    }
-    closedir($dir);
-    $res = rmdir($path);
-    clearstatcache();
-    return $res;
-  }
-
-  //make multiprocess test someday
-  function testSafeWrite()
-  {
-    lmbFs :: safeWrite(LIMB_VAR_DIR . '/test', 'test');
-    $this->assertEqual('test',
-                       file_get_contents(LIMB_VAR_DIR . '/test'));
-  }
-
-  function testJoinPath()
-  {
-    $path = lmbFs :: joinPath(array('wow', 'hey', 'yo'), lmbFs :: UNIX);
-    $this->assertEqual($path, 'wow/hey/yo');
-  }
-
-  function testRemoveNoSuchFile()
-  {
-    $this->assertFalse(lmbFs :: rm('blaaaaaaaaaaaaaaaah'));
-  }
-
-  function testRemoveFile()
-  {
-    lmbFs :: safeWrite($file = LIMB_VAR_DIR . '/test', 'test');
-    $this->assertTrue(lmbFs :: rm($file));
-    $this->assertFalse(file_exists($file));
-  }
-
-  function testRemoveDirectory()
-  {
-    $this->_createFileSystem();
-
-    $this->assertTrue(lmbFs :: rm(LIMB_VAR_DIR . '/tmp/'));
-    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/'));
-  }
-
-  function testIsPathAbsolute()
-  {
-    $this->assertTrue(lmbFs :: isPathAbsolute('c:/var/wow', lmbFs :: DOS));
-    $this->assertTrue(lmbFs :: isPathAbsolute('/var/wow', lmbFs :: UNIX));
-    $this->assertTrue(lmbFs :: isPathAbsolute('/var/wow', lmbFs :: DOS));
-    $this->assertFalse(lmbFs :: isPathAbsolute('c:/var/wow', lmbFs :: UNIX));
-
-    $this->assertFalse(lmbFs :: isPathAbsolute('var/wow'));
-  }
-
-  function testNormalizeUglyPath()
-  {
-    $path = lmbFs :: normalizePath('/tmp\../tmp/wow////hey/');
-    $this->assertEqual($path, lmbFs :: separator() . 'tmp' . lmbFs :: separator() . 'wow' . lmbFs :: separator() . 'hey');
-
-    $path = lmbFs :: normalizePath('tmp\../tmp/wow////hey/');
-    $this->assertEqual($path, 'tmp' . lmbFs :: separator() . 'wow' . lmbFs :: separator() . 'hey');
-  }
-
-  function testNormalizePathForWindows()
-  {
-    $path = lmbFs :: normalizePath('c:\\var\\dev\\demo\\design\\templates\\test.html');
-
-    $this->assertEqual($path,
-      'c:' . lmbFs :: separator() .
-      'var' . lmbFs :: separator() .
-      'dev' . lmbFs :: separator() .
-      'demo' . lmbFs :: separator() .
-      'design' . lmbFs :: separator() .
-      'templates' . lmbFs :: separator() .
-      'test.html');
-  }
-
-  function testNormalizePathTrimTrailingSlashes()
-  {
-    $path1 = lmbFs :: normalizePath('/tmp/wow////hey/\\');
-    $path2 = lmbFs :: normalizePath('/tmp\\wow//../wow/hey');
-    $this->assertEqual($path1, $path2);
-    $this->assertEqual($path1, lmbFs :: separator() . 'tmp' . lmbFs :: separator() . 'wow' . lmbFs :: separator() . 'hey');
-  }
-
-  function testExplodeAbsolutePath()
-  {
-    $path = lmbFs :: explodePath('/tmp\../tmp/wow////hey/');
-
-    $this->assertEqual(sizeof($path), 4);
-
-    $this->assertEqual($path[0], '');
-    $this->assertEqual($path[1], 'tmp');
-    $this->assertEqual($path[2], 'wow');
-    $this->assertEqual($path[3], 'hey');
-
-    $path = lmbFs :: explodePath('/tmp\../tmp/wow////hey'); // no trailing slash
-
-    $this->assertEqual(sizeof($path), 4);
-
-    $this->assertEqual($path[0], '');
-    $this->assertEqual($path[1], 'tmp');
-    $this->assertEqual($path[2], 'wow');
-    $this->assertEqual($path[3], 'hey');
-  }
-
-  function testExplodeRelativePath()
-  {
-    $path = lmbFs :: explodePath('tmp\../tmp/wow////hey/');
-
-    $this->assertEqual(sizeof($path), 3);
-
-    $this->assertEqual($path[0], 'tmp');
-    $this->assertEqual($path[1], 'wow');
-    $this->assertEqual($path[2], 'hey');
-
-    $path = lmbFs :: explodePath('tmp\../tmp/wow////hey'); // no trailing slash
-
-    $this->assertEqual(sizeof($path), 3);
-
-    $this->assertEqual($path[0], 'tmp');
-    $this->assertEqual($path[1], 'wow');
-    $this->assertEqual($path[2], 'hey');
-  }
-
-  function testMkdirAbsolutePath()
-  {
-    lmbFs :: rm(LIMB_VAR_DIR . '/tmp/');
-
-    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/wow/hey/'));
-
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/./tmp\../tmp/wow////hey/');
-
-    $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/wow/hey/'));
-  }
-
-  function testDirpath()
-  {
-    $this->assertEqual(lmbFs :: dirpath('/wow/test.txt'), lmbFs :: normalizePath('/wow'));
-    $this->assertEqual(lmbFs :: dirpath('wow/hey/test.txt'), lmbFs :: normalizePath('wow/hey'));
-    $this->assertEqual(lmbFs :: dirpath('test.txt'), 'test.txt');
-    $this->assertEqual(lmbFs :: dirpath('/'), '');
-  }
-
-  function testLs()
-  {
-    $this->_createFileSystem();
-
-    $a1 = array('test1_1', 'test1_2', 'test1_3', 'wow');
-    sort($a1);
-    $a2 =  lmbFs :: ls(LIMB_VAR_DIR . '/tmp/');
-    sort($a2);
-
-    $this->assertEqual($a1, $a2);
-    $this->assertEqual(array('hey', 'test2_1', 'test2_2', 'test2_3'), lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testPath()
-  {
-    $this->assertEqual(lmbFs :: path(array('test')), 'test');
-    $this->assertEqual(lmbFs :: path(array('test', 'wow')), 'test' . lmbFs :: separator() . 'wow');
-    $this->assertEqual(lmbFs :: path(array('test', 'wow/')), 'test' . lmbFs :: separator() . 'wow');
-
-    $this->assertEqual(lmbFs :: path(array('test'), true), 'test' . lmbFs :: separator());
-    $this->assertEqual(lmbFs :: path(array('test', 'wow'), true), 'test' . lmbFs :: separator() . 'wow' . lmbFs :: separator());
-  }
-
-  function testChop()
-  {
-    $this->assertEqual(lmbFs :: chop('test'), 'test');
-    $this->assertEqual(lmbFs :: chop('test/'), 'test');
-    $this->assertEqual(lmbFs :: chop('test\\'), 'test');
-  }
-
-  function testWalkDir()
-  {
-    $this->_createFileSystem();
-
-    $mock = new SpecialDirWalker();
-
-    $this->assertEqual(
-      lmbFs :: walkDir(LIMB_VAR_DIR . '/tmp/',
-                    array(&$mock, 'walk'),
-                    array('test')),
-      array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
-    );
-
-    sort($mock->walked);
-
-    $this->assertEqual(sizeof($mock->walked), 11);
-
-    $this->assertEqual($mock->walked[0], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_1'));
-    $this->assertEqual($mock->walked[1], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_2'));
-    $this->assertEqual($mock->walked[2], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_3'));
-    $this->assertEqual($mock->walked[3], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow'));
-    $this->assertEqual($mock->walked[4], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey'));
-    $this->assertEqual($mock->walked[5], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'));
-    $this->assertEqual($mock->walked[6], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2'));
-    $this->assertEqual($mock->walked[7], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3'));
-    $this->assertEqual($mock->walked[8], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_1'));
-    $this->assertEqual($mock->walked[9], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_2'));
-    $this->assertEqual($mock->walked[10], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_3'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testWalkDirIncludeFirst()
-  {
-    $this->_createFileSystem();
-
-    $mock = new SpecialDirWalker();
-
-    $this->assertEqual(
-      $res = lmbFs :: walkDir(LIMB_VAR_DIR . '/tmp/',
-                     array(&$mock, 'walk'),
-                     array('test'),
-                     true),
-      array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-    );
-
-    sort($mock->walked);
-
-    $this->assertEqual(sizeof($mock->walked), 12);
-
-    $this->assertEqual($mock->walked[0], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp'));
-    $this->assertEqual($mock->walked[1], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_1'));
-    $this->assertEqual($mock->walked[2], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_2'));
-    $this->assertEqual($mock->walked[3], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_3'));
-    $this->assertEqual($mock->walked[4], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow'));
-    $this->assertEqual($mock->walked[5], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey'));
-    $this->assertEqual($mock->walked[6], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'));
-    $this->assertEqual($mock->walked[7], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2'));
-    $this->assertEqual($mock->walked[8], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3'));
-    $this->assertEqual($mock->walked[9], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_1'));
-    $this->assertEqual($mock->walked[10], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_2'));
-    $this->assertEqual($mock->walked[11], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_3'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testMv()
-  {
-    $this->_createFileSystem();
-
-    lmbFs :: mv(LIMB_VAR_DIR . '/tmp/wow',
-                LIMB_VAR_DIR . '/tmp/whatever');
-
-    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/wow'));
-    $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/whatever'));
-  }
-
-  function testMoveOntoItselfDoesNothing()
-  {
-    $this->_createFileSystem();
-
-    lmbFs :: mv(LIMB_VAR_DIR . '/tmp/wow',
-                LIMB_VAR_DIR . '/tmp/wow');
-
-    $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/wow'));
-  }
-
-  function testMoveNonExistingFails()
-  {
-    $this->_createFileSystem();
-
-    try
-    {
-      lmbFs :: mv(LIMB_VAR_DIR . '/tmp/blaaah',
-                  LIMB_VAR_DIR . '/tmp/cp');
-      $this->assertFalse(true);
-    }
-    catch(lmbFsException $e){}
-  }
-
-  function testCpDirs()
-  {
-    $this->_createFileSystem();
-
-    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
-                       LIMB_VAR_DIR . '/tmp/cp');
-    sort($res);
-
-    $this->assertEqual(
-      $res,
-      array(
-      'hey',
-      lmbFs :: normalizePath('hey/test3_1'),
-      lmbFs :: normalizePath('hey/test3_2'),
-      lmbFs :: normalizePath('hey/test3_3'),
-      'test2_1',
-      'test2_2',
-      'test2_3',
-      )
-    );
-
-    $this->assertEqual(
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp'),
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow'));
-
-    $this->assertEqual(
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/hey'),
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow/hey'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testCpAsChild()
-  {
-    $this->_createFileSystem();
-
-    lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
-                LIMB_VAR_DIR . '/tmp/cp', null, null, true);
-
-    $this->assertEqual(
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/wow/'),
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow'));
-
-    $this->assertEqual(
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/wow/hey'),
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow/hey'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testCpDirsWithExclude()
-  {
-    $this->_createFileSystem();
-
-    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
-                       LIMB_VAR_DIR . '/tmp/cp', '/hey/');
-    sort($res);
-
-    $this->assertEqual(
-      $res,
-      array('test2_1', 'test2_2', 'test2_3')
-    );
-
-    $this->assertEqual(
-      $res,
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/')
-    );
-
-    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/cp/hey'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testCpDirsWithInclude()
-  {
-    $this->_createFileSystem();
-
-    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
-                       LIMB_VAR_DIR . '/tmp/cp', null, '/test2/');
-
-    $this->assertEqual(
-      $res,
-      array('test2_1', 'test2_2', 'test2_3')
-    );
-
-    $this->assertEqual(
-      $res,
-      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/')
-    );
-
-    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/cp/hey'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testCpFileIntoNonExistingFile()
-  {
-    $this->_createFileSystem();
-
-    $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/test1_1_1'));
-
-    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/test1_1',
-                        LIMB_VAR_DIR . '/tmp/test1_1_1');
-
-    $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/test1_1_1'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testCpFileIntoExistingDir()
-  {
-    $this->_createFileSystem();
-
-    $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/wow/test1_1'));
-
-    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/test1_1',
-                        LIMB_VAR_DIR . '/tmp/wow');
-
-    $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/wow/test1_1'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testCpFileIntoNonExistingDir()
-  {
-    $this->_createFileSystem();
-
-    $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy'));
-
-    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/test1_1',
-                        LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy');
-
-    $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy'));
-
-    $this->_removeFileSystem();
-  }
-
-  function testFind()
-  {
-    $this->_createFileSystem();
-
-    $res = lmbFs :: find(LIMB_VAR_DIR . '/tmp/wow/hey');
-    sort($res);
-
-    $this->assertEqual(
-      $res,
-      array(
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'),
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2'),
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3')
-      )
-    );
-
-    $res = lmbFs :: find(LIMB_VAR_DIR . '/tmp/wow/', 'f', null, '/^test2_1$/');
-    sort($res);
-
-    $this->assertEqual(
-      $res,
-      array(
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_2'),
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_3'),
-      )
-    );
-
-    $this->_removeFileSystem();
-  }
-
-  function testFindRecursive()
-  {
-    $this->_createFileSystem();
-
-    $res = lmbFs :: findRecursive(LIMB_VAR_DIR . '/tmp/', 'fd', '~test\d_1~');
-    sort($res);
-
-    $this->assertEqual(
-      $res,
-      array(
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_1'),
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'),
-        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_1'),
-      )
-    );
-
-    $this->_removeFileSystem();
-  }
-}
-
+ */
+lmb_require('limb/fs/src/lmbFs.class.php');
 
+class SpecialDirWalker
+{
+  var $walked = array();
+  var $counter = 0;
+
+  function walk($dir, $file, $path, $params, &$return_params)
+  {
+    $this->walked[] = lmbFs :: normalizePath($path);
+    $return_params[] = $this->counter++;
+  }
+}
+
+class lmbFsTest extends UnitTestCase
+{
+  function _createFileSystem()
+  {
+    lmbFs :: mkdir(LIMB_VAR_DIR . '/tmp/wow/hey/');
+
+    touch(LIMB_VAR_DIR . '/tmp/test1_1');
+    touch(LIMB_VAR_DIR . '/tmp/test1_2');
+    touch(LIMB_VAR_DIR . '/tmp/test1_3');
+
+    touch(LIMB_VAR_DIR . '/tmp/wow/test2_1');
+    touch(LIMB_VAR_DIR . '/tmp/wow/test2_2');
+    touch(LIMB_VAR_DIR . '/tmp/wow/test2_3');
+
+    touch(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1');
+    touch(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2');
+    touch(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3');
+  }
+
+  function _removeFileSystem()
+  {
+    $this->_rmdir(LIMB_VAR_DIR . '/tmp/');
+  }
+
+  function _rmdir($path)
+  {
+    if(!is_dir($path))
+      return;
+
+    $dir = opendir($path);
+    while($entry = readdir($dir))
+    {
+      if(is_file("$path/$entry"))
+        unlink("$path/$entry");
+      elseif(is_dir("$path/$entry") && $entry != '.' && $entry != '..')
+        $this->_rmdir("$path/$entry");
+    }
+    closedir($dir);
+    $res = rmdir($path);
+    clearstatcache();
+    return $res;
+  }
+
+  //make multiprocess test someday
+  function testSafeWrite()
+  {
+    lmbFs :: safeWrite(LIMB_VAR_DIR . '/test', 'test');
+    $this->assertEqual('test',
+                       file_get_contents(LIMB_VAR_DIR . '/test'));
+  }
+
+  function testJoinPath()
+  {
+    $path = lmbFs :: joinPath(array('wow', 'hey', 'yo'), lmbFs :: UNIX);
+    $this->assertEqual($path, 'wow/hey/yo');
+  }
+
+  function testRemoveNoSuchFile()
+  {
+    $this->assertFalse(lmbFs :: rm('blaaaaaaaaaaaaaaaah'));
+  }
+
+  function testRemoveFile()
+  {
+    lmbFs :: safeWrite($file = LIMB_VAR_DIR . '/test', 'test');
+    $this->assertTrue(lmbFs :: rm($file));
+    $this->assertFalse(file_exists($file));
+  }
+
+  function testRemoveDirectory()
+  {
+    $this->_createFileSystem();
+
+    $this->assertTrue(lmbFs :: rm(LIMB_VAR_DIR . '/tmp/'));
+    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/'));
+  }
+
+  function testIsPathAbsolute()
+  {
+    $this->assertTrue(lmbFs :: isPathAbsolute('c:/var/wow', lmbFs :: DOS));
+    $this->assertTrue(lmbFs :: isPathAbsolute('/var/wow', lmbFs :: UNIX));
+    $this->assertTrue(lmbFs :: isPathAbsolute('/var/wow', lmbFs :: DOS));
+    $this->assertFalse(lmbFs :: isPathAbsolute('c:/var/wow', lmbFs :: UNIX));
+
+    $this->assertFalse(lmbFs :: isPathAbsolute('var/wow'));
+  }
+
+  function testNormalizeUglyPath()
+  {
+    $path = lmbFs :: normalizePath('/tmp\../tmp/wow////hey/');
+    $this->assertEqual($path, lmbFs :: separator() . 'tmp' . lmbFs :: separator() . 'wow' . lmbFs :: separator() . 'hey');
+
+    $path = lmbFs :: normalizePath('tmp\../tmp/wow////hey/');
+    $this->assertEqual($path, 'tmp' . lmbFs :: separator() . 'wow' . lmbFs :: separator() . 'hey');
+  }
+
+  function testNormalizePathForWindows()
+  {
+    $path = lmbFs :: normalizePath('c:\\var\\dev\\demo\\design\\templates\\test.html');
+
+    $this->assertEqual($path,
+      'c:' . lmbFs :: separator() .
+      'var' . lmbFs :: separator() .
+      'dev' . lmbFs :: separator() .
+      'demo' . lmbFs :: separator() .
+      'design' . lmbFs :: separator() .
+      'templates' . lmbFs :: separator() .
+      'test.html');
+  }
+
+  function testNormalizePathTrimTrailingSlashes()
+  {
+    $path1 = lmbFs :: normalizePath('/tmp/wow////hey/\\');
+    $path2 = lmbFs :: normalizePath('/tmp\\wow//../wow/hey');
+    $this->assertEqual($path1, $path2);
+    $this->assertEqual($path1, lmbFs :: separator() . 'tmp' . lmbFs :: separator() . 'wow' . lmbFs :: separator() . 'hey');
+  }
+
+  function testExplodeAbsolutePath()
+  {
+    $path = lmbFs :: explodePath('/tmp\../tmp/wow////hey/');
+
+    $this->assertEqual(sizeof($path), 4);
+
+    $this->assertEqual($path[0], '');
+    $this->assertEqual($path[1], 'tmp');
+    $this->assertEqual($path[2], 'wow');
+    $this->assertEqual($path[3], 'hey');
+
+    $path = lmbFs :: explodePath('/tmp\../tmp/wow////hey'); // no trailing slash
+
+    $this->assertEqual(sizeof($path), 4);
+
+    $this->assertEqual($path[0], '');
+    $this->assertEqual($path[1], 'tmp');
+    $this->assertEqual($path[2], 'wow');
+    $this->assertEqual($path[3], 'hey');
+  }
+
+  function testExplodeRelativePath()
+  {
+    $path = lmbFs :: explodePath('tmp\../tmp/wow////hey/');
+
+    $this->assertEqual(sizeof($path), 3);
+
+    $this->assertEqual($path[0], 'tmp');
+    $this->assertEqual($path[1], 'wow');
+    $this->assertEqual($path[2], 'hey');
+
+    $path = lmbFs :: explodePath('tmp\../tmp/wow////hey'); // no trailing slash
+
+    $this->assertEqual(sizeof($path), 3);
+
+    $this->assertEqual($path[0], 'tmp');
+    $this->assertEqual($path[1], 'wow');
+    $this->assertEqual($path[2], 'hey');
+  }
+
+  function testMkdirAbsolutePath()
+  {
+    lmbFs :: rm(LIMB_VAR_DIR . '/tmp/');
+
+    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/wow/hey/'));
+
+    lmbFs :: mkdir(LIMB_VAR_DIR . '/./tmp\../tmp/wow////hey/');
+
+    $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/wow/hey/'));
+  }
+
+  function testDirpath()
+  {
+    $this->assertEqual(lmbFs :: dirpath('/wow/test.txt'), lmbFs :: normalizePath('/wow'));
+    $this->assertEqual(lmbFs :: dirpath('wow/hey/test.txt'), lmbFs :: normalizePath('wow/hey'));
+    $this->assertEqual(lmbFs :: dirpath('test.txt'), 'test.txt');
+    $this->assertEqual(lmbFs :: dirpath('/'), '');
+  }
+
+  function testLs()
+  {
+    $this->_createFileSystem();
+
+    $a1 = array('test1_1', 'test1_2', 'test1_3', 'wow');
+    sort($a1);
+    $a2 =  lmbFs :: ls(LIMB_VAR_DIR . '/tmp/');
+    sort($a2);
+
+    $this->assertEqual($a1, $a2);
+    $this->assertEqual(array('hey', 'test2_1', 'test2_2', 'test2_3'), lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testPath()
+  {
+    $this->assertEqual(lmbFs :: path(array('test')), 'test');
+    $this->assertEqual(lmbFs :: path(array('test', 'wow')), 'test' . lmbFs :: separator() . 'wow');
+    $this->assertEqual(lmbFs :: path(array('test', 'wow/')), 'test' . lmbFs :: separator() . 'wow');
+
+    $this->assertEqual(lmbFs :: path(array('test'), true), 'test' . lmbFs :: separator());
+    $this->assertEqual(lmbFs :: path(array('test', 'wow'), true), 'test' . lmbFs :: separator() . 'wow' . lmbFs :: separator());
+  }
+
+  function testChop()
+  {
+    $this->assertEqual(lmbFs :: chop('test'), 'test');
+    $this->assertEqual(lmbFs :: chop('test/'), 'test');
+    $this->assertEqual(lmbFs :: chop('test\\'), 'test');
+  }
+
+  function testWalkDir()
+  {
+    $this->_createFileSystem();
+
+    $mock = new SpecialDirWalker();
+
+    $this->assertEqual(
+      lmbFs :: walkDir(LIMB_VAR_DIR . '/tmp/',
+                    array(&$mock, 'walk'),
+                    array('test')),
+      array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
+    );
+
+    sort($mock->walked);
+
+    $this->assertEqual(sizeof($mock->walked), 11);
+
+    $this->assertEqual($mock->walked[0], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_1'));
+    $this->assertEqual($mock->walked[1], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_2'));
+    $this->assertEqual($mock->walked[2], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_3'));
+    $this->assertEqual($mock->walked[3], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow'));
+    $this->assertEqual($mock->walked[4], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey'));
+    $this->assertEqual($mock->walked[5], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'));
+    $this->assertEqual($mock->walked[6], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2'));
+    $this->assertEqual($mock->walked[7], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3'));
+    $this->assertEqual($mock->walked[8], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_1'));
+    $this->assertEqual($mock->walked[9], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_2'));
+    $this->assertEqual($mock->walked[10], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_3'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testWalkDirIncludeFirst()
+  {
+    $this->_createFileSystem();
+
+    $mock = new SpecialDirWalker();
+
+    $this->assertEqual(
+      $res = lmbFs :: walkDir(LIMB_VAR_DIR . '/tmp/',
+                     array(&$mock, 'walk'),
+                     array('test'),
+                     true),
+      array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
+    );
+
+    sort($mock->walked);
+
+    $this->assertEqual(sizeof($mock->walked), 12);
+
+    $this->assertEqual($mock->walked[0], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp'));
+    $this->assertEqual($mock->walked[1], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_1'));
+    $this->assertEqual($mock->walked[2], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_2'));
+    $this->assertEqual($mock->walked[3], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_3'));
+    $this->assertEqual($mock->walked[4], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow'));
+    $this->assertEqual($mock->walked[5], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey'));
+    $this->assertEqual($mock->walked[6], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'));
+    $this->assertEqual($mock->walked[7], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2'));
+    $this->assertEqual($mock->walked[8], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3'));
+    $this->assertEqual($mock->walked[9], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_1'));
+    $this->assertEqual($mock->walked[10], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_2'));
+    $this->assertEqual($mock->walked[11], lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_3'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testMv()
+  {
+    $this->_createFileSystem();
+
+    lmbFs :: mv(LIMB_VAR_DIR . '/tmp/wow',
+                LIMB_VAR_DIR . '/tmp/whatever');
+
+    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/wow'));
+    $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/whatever'));
+  }
+
+  function testMoveOntoItselfDoesNothing()
+  {
+    $this->_createFileSystem();
+
+    lmbFs :: mv(LIMB_VAR_DIR . '/tmp/wow',
+                LIMB_VAR_DIR . '/tmp/wow');
+
+    $this->assertTrue(is_dir(LIMB_VAR_DIR . '/tmp/wow'));
+  }
+
+  function testMoveNonExistingFails()
+  {
+    $this->_createFileSystem();
+
+    try
+    {
+      lmbFs :: mv(LIMB_VAR_DIR . '/tmp/blaaah',
+                  LIMB_VAR_DIR . '/tmp/cp');
+      $this->assertFalse(true);
+    }
+    catch(lmbFsException $e){}
+  }
+
+  function testCpDirs()
+  {
+    $this->_createFileSystem();
+
+    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
+                       LIMB_VAR_DIR . '/tmp/cp');
+    sort($res);
+
+    $this->assertEqual(
+      $res,
+      array(
+      'hey',
+      lmbFs :: normalizePath('hey/test3_1'),
+      lmbFs :: normalizePath('hey/test3_2'),
+      lmbFs :: normalizePath('hey/test3_3'),
+      'test2_1',
+      'test2_2',
+      'test2_3',
+      )
+    );
+
+    $this->assertEqual(
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp'),
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow'));
+
+    $this->assertEqual(
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/hey'),
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow/hey'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testCpAsChild()
+  {
+    $this->_createFileSystem();
+
+    lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
+                LIMB_VAR_DIR . '/tmp/cp', null, null, true);
+
+    $this->assertEqual(
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/wow/'),
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow'));
+
+    $this->assertEqual(
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/wow/hey'),
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/wow/hey'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testCpDirsWithExclude()
+  {
+    $this->_createFileSystem();
+
+    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
+                       LIMB_VAR_DIR . '/tmp/cp', '/hey/');
+    sort($res);
+
+    $this->assertEqual(
+      $res,
+      array('test2_1', 'test2_2', 'test2_3')
+    );
+
+    $this->assertEqual(
+      $res,
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/')
+    );
+
+    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/cp/hey'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testCpDirsWithInclude()
+  {
+    $this->_createFileSystem();
+
+    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/wow',
+                       LIMB_VAR_DIR . '/tmp/cp', null, '/test2/');
+
+    $this->assertEqual(
+      $res,
+      array('test2_1', 'test2_2', 'test2_3')
+    );
+
+    $this->assertEqual(
+      $res,
+      lmbFs :: ls(LIMB_VAR_DIR . '/tmp/cp/')
+    );
+
+    $this->assertFalse(is_dir(LIMB_VAR_DIR . '/tmp/cp/hey'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testCpFileIntoNonExistingFile()
+  {
+    $this->_createFileSystem();
+
+    $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/test1_1_1'));
+
+    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/test1_1',
+                        LIMB_VAR_DIR . '/tmp/test1_1_1');
+
+    $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/test1_1_1'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testCpFileIntoExistingDir()
+  {
+    $this->_createFileSystem();
+
+    $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/wow/test1_1'));
+
+    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/test1_1',
+                        LIMB_VAR_DIR . '/tmp/wow');
+
+    $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/wow/test1_1'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testCpFileIntoNonExistingDir()
+  {
+    $this->_createFileSystem();
+
+    $this->assertFalse(file_exists(LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy'));
+
+    $res = lmbFs :: cp(LIMB_VAR_DIR . '/tmp/test1_1',
+                        LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy');
+
+    $this->assertTrue(file_exists(LIMB_VAR_DIR . '/tmp/wow2/test1_1.copy'));
+
+    $this->_removeFileSystem();
+  }
+
+  function testFind()
+  {
+    $this->_createFileSystem();
+
+    $res = lmbFs :: find(LIMB_VAR_DIR . '/tmp/wow/hey');
+    sort($res);
+
+    $this->assertEqual(
+      $res,
+      array(
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'),
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_2'),
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_3')
+      )
+    );
+
+    $res = lmbFs :: find(LIMB_VAR_DIR . '/tmp/wow/', 'f', null, '/^test2_1$/');
+    sort($res);
+
+    $this->assertEqual(
+      $res,
+      array(
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_2'),
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_3'),
+      )
+    );
+
+    $this->_removeFileSystem();
+  }
+
+  function testFindRecursive()
+  {
+    $this->_createFileSystem();
+
+    $res = lmbFs :: findRecursive(LIMB_VAR_DIR . '/tmp/', 'fd', '~test\d_1~');
+    sort($res);
+
+    $this->assertEqual(
+      $res,
+      array(
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/test1_1'),
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/hey/test3_1'),
+        lmbFs :: normalizePath(LIMB_VAR_DIR . '/tmp/wow/test2_1'),
+      )
+    );
+
+    $this->_removeFileSystem();
+  }
+}
+
+



More information about the limb-svn mailing list