[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/tests_runner/src/ -> lmbTestTreeShallowDirNode.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__) . '/lmbTestTreeNode.class.php');
  10  require_once(dirname(__FILE__) . '/lmbDetachedFixture.class.php');
  11  
  12  /**

  13   * class lmbTestTreeShallowDirNode.

  14   *

  15   * @package tests_runner

  16   * @version $Id: lmbTestTreeShallowDirNode.class.php 6020 2007-06-27 15:12:32Z pachanga $

  17   */
  18  class lmbTestTreeShallowDirNode extends lmbTestTreeNode
  19  {
  20    protected $dir;
  21    protected $skipped;
  22  
  23    function __construct($dir)
  24    {
  25      if(!is_dir($dir))
  26        throw new Exception("'$dir' is not a directory!");
  27  
  28      $this->dir = $dir;
  29    }
  30  
  31    static function hasArtifacts($dir)
  32    {
  33      $artifacts = array('.init.php',
  34                         '.setup.php',
  35                         '.teardown.php',
  36                         '.ignore.php',
  37                         '.skipif.php');
  38      foreach($artifacts as $artifact)
  39      {
  40        if(file_exists($dir . '/' . $artifact))
  41          return true;
  42      }
  43      return false;
  44    }
  45  
  46  
  47    function getDir()
  48    {
  49      return $this->dir;
  50    }
  51  
  52  
  53    function init()
  54    {
  55      if(file_exists($this->dir . '/.init.php'))
  56        include_once($this->dir . '/.init.php');
  57    }
  58  
  59    protected function _doCreateTestCase()
  60    {
  61      require_once(dirname(__FILE__) . '/lmbTestGroup.class.php');
  62  
  63      $label = $this->_getDirectoryLabel();
  64      $test = new lmbTestGroup($label);
  65      $fixture = new lmbDetachedFixture($this->dir . '/.setup.php',
  66                                        $this->dir . '/.teardown.php');
  67      $test->useFixture($fixture);
  68      return $test;
  69    }
  70  
  71    protected function _getDirectoryLabel()
  72    {
  73      if(file_exists($this->dir . '/.description'))
  74        return file_get_contents($this->dir . '/.description');
  75      else
  76        return 'Group test in "' . $this->dir . '"';
  77    }
  78  
  79    function isSkipped()
  80    {
  81      if(!is_null($this->skipped))
  82        return $this->skipped;
  83  
  84      if(file_exists($this->dir . '/.skipif.php'))
  85        $this->skipped = (bool)include($this->dir . '/.skipif.php');
  86      elseif(file_exists($this->dir . '/.ignore.php'))
  87        $this->skipped = (bool)include($this->dir . '/.ignore.php');
  88      else
  89        $this->skipped = false;
  90  
  91      return $this->skipped;
  92    }
  93  }
  94  
  95  ?>


Generated: Tue Dec 2 03:54:09 2008 Cross-referenced by PHPXref 0.7