[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/tests_runner/tests/cases/ -> lmbTestTreeFilePathNodeTest.class.php (source)

   1  <?php
   2  /*

   3   * Limb PHP Framework

   4   *

   5   * @link http://limb-project.com

   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)

   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html

   8   */
   9  require_once(dirname(__FILE__) . '/../common.inc.php');
  10  require_once(dirname(__FILE__) . '/../../src/lmbTestTreeFilePathNode.class.php');
  11  
  12  class lmbTestTreeFilePathNodeTest extends lmbTestRunnerBase
  13  {
  14    protected $var_dir;
  15  
  16    function setUp()
  17    {
  18      $this->_rmdir(LIMB_VAR_DIR);
  19      //we need unique temporary dir since test modules are included once

  20      $this->var_dir = LIMB_VAR_DIR . '/' . mt_rand();
  21      mkdir(LIMB_VAR_DIR);
  22      mkdir($this->var_dir);
  23    }
  24  
  25    function tearDown()
  26    {
  27      $this->_rmdir(LIMB_VAR_DIR);
  28    }
  29  
  30    function testLoadChildrenForFilePathEndingWithFile()
  31    {
  32      mkdir($this->var_dir . '/a');
  33      mkdir($this->var_dir . '/a/b');
  34      touch($this->var_dir . '/a/b/bar_test.php');
  35      touch($this->var_dir . '/a/b/foo_test.php');
  36  
  37      $node = new lmbTestTreeFilePathNode($this->var_dir . '/a/b/foo_test.php', -3);
  38      $kids = $node->getChildren();
  39      $this->assertEqual(sizeof($kids), 1);
  40      $this->assertIsA($kids[0], 'lmbTestTreeShallowDirNode');
  41      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a'));
  42  
  43      $kids = $kids[0]->getChildren();
  44      $this->assertEqual(sizeof($kids), 1);
  45      $this->assertIsA($kids[0], 'lmbTestTreeShallowDirNode');
  46      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a/b'));
  47  
  48      $kids = $kids[0]->getChildren();
  49      $this->assertEqual(sizeof($kids), 1);
  50      $this->assertIsA($kids[0], 'lmbTestTreeFileNode');
  51      $this->assertEqual($kids[0]->getFile(), realpath($this->var_dir . '/a/b/foo_test.php'));
  52    }
  53  
  54    function testLoadChildrenForFilePathEndingWithDir()
  55    {
  56      mkdir($this->var_dir . '/a');
  57      mkdir($this->var_dir . '/a/b');
  58      touch($this->var_dir . '/a/b/bar_test.php');
  59      touch($this->var_dir . '/a/b/foo_test.php');
  60  
  61      $node = new lmbTestTreeFilePathNode($this->var_dir . '/a/b', -2);
  62      $kids = $node->getChildren();
  63      $this->assertEqual(sizeof($kids), 1);
  64      $this->assertIsA($kids[0], 'lmbTestTreeShallowDirNode');
  65      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a'));
  66  
  67      $kids = $kids[0]->getChildren();
  68      $this->assertEqual(sizeof($kids), 1);
  69      $this->assertIsA($kids[0], 'lmbTestTreeDirNode');
  70      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a/b'));
  71    }
  72  
  73    function testLoadChildrenUseAutoOffsetForFile()
  74    {
  75      mkdir($this->var_dir . '/a');
  76      mkdir($this->var_dir . '/a/b');
  77      touch($this->var_dir . '/a/b/bar_test.php');
  78      touch($this->var_dir . '/a/b/foo_test.php');
  79  
  80      $node = new lmbTestTreeFilePathNode($this->var_dir . '/a/b/bar_test.php');
  81      $kids = $node->getChildren();
  82      $this->assertEqual(sizeof($kids), 1);
  83      $this->assertIsA($kids[0], 'lmbTestTreeFileNode');
  84      $this->assertEqual($kids[0]->getFile(), realpath($this->var_dir . '/a/b/bar_test.php'));
  85    }
  86  
  87    function testLoadChildrenUseAutoOffsetForFileWithArtifacts()
  88    {
  89      mkdir($this->var_dir . '/a');
  90      mkdir($this->var_dir . '/a/b');
  91      file_put_contents($this->var_dir . '/a/.skipif.php', '<?php return false; ?>');
  92      touch($this->var_dir . '/a/b/bar_test.php');
  93      touch($this->var_dir . '/a/b/foo_test.php');
  94  
  95      $node = new lmbTestTreeFilePathNode($this->var_dir . '/a/b/bar_test.php');
  96      $kids = $node->getChildren();
  97      $this->assertEqual(sizeof($kids), 1);
  98      $this->assertIsA($kids[0], 'lmbTestTreeShallowDirNode');
  99      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a'));
 100  
 101      $kids = $kids[0]->getChildren();
 102      $this->assertEqual(sizeof($kids), 1);
 103      $this->assertIsA($kids[0], 'lmbTestTreeShallowDirNode');
 104      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a/b'));
 105  
 106      $kids = $kids[0]->getChildren();
 107      $this->assertEqual(sizeof($kids), 1);
 108      $this->assertIsA($kids[0], 'lmbTestTreeFileNode');
 109      $this->assertEqual($kids[0]->getFile(), realpath($this->var_dir . '/a/b/bar_test.php'));
 110    }
 111  
 112    function testLoadChildrenUseAutoOffsetForDir()
 113    {
 114      mkdir($this->var_dir . '/a');
 115      mkdir($this->var_dir . '/a/b');
 116      touch($this->var_dir . '/a/b/bar_test.php');
 117      touch($this->var_dir . '/a/b/foo_test.php');
 118  
 119      $node = new lmbTestTreeFilePathNode($this->var_dir . '/a/b/');
 120      $kids = $node->getChildren();
 121      $this->assertEqual(sizeof($kids), 1);
 122      $this->assertIsA($kids[0], 'lmbTestTreeDirNode');
 123      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a/b'));
 124    }
 125  
 126    function testLoadChildrenUseAutoOffsetForDirWithArtifacts()
 127    {
 128      mkdir($this->var_dir . '/a');
 129      mkdir($this->var_dir . '/a/b');
 130      file_put_contents($this->var_dir . '/a/.skipif.php', '<?php return false; ?>');
 131      touch($this->var_dir . '/a/b/bar_test.php');
 132      touch($this->var_dir . '/a/b/foo_test.php');
 133  
 134      $node = new lmbTestTreeFilePathNode($this->var_dir . '/a/b');
 135      $kids = $node->getChildren();
 136      $this->assertEqual(sizeof($kids), 1);
 137      $this->assertIsA($kids[0], 'lmbTestTreeShallowDirNode');
 138      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a'));
 139  
 140      $kids = $kids[0]->getChildren();
 141      $this->assertEqual(sizeof($kids), 1);
 142      $this->assertIsA($kids[0], 'lmbTestTreeDirNode');
 143      $this->assertEqual($kids[0]->getDir(), realpath($this->var_dir . '/a/b'));
 144    }
 145  }
 146  
 147  ?>


Generated: Fri Aug 29 04:49:26 2008 Cross-referenced by PHPXref 0.7