[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/fs/tests/cases/ -> lmbFileLocatorTest.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  lmb_require('limb/fs/src/lmbFileLocations.interface.php');
  10  lmb_require('limb/fs/src/lmbFileLocator.class.php');
  11  lmb_require('limb/fs/src/lmbFs.class.php');
  12  
  13  Mock :: generate('lmbFileLocations', 'MockFileLocaions');
  14  
  15  class lmbFileLocatorTest extends UnitTestCase
  16  {
  17    function testLocateException()
  18    {
  19      $locator = new lmbFileLocator($mock = new MockFileLocations());
  20  
  21      $params = array('whatever');
  22      $mock->expectOnce('getLocations', array($params));
  23      $mock->setReturnValue('getLocations', array());
  24  
  25      try
  26      {
  27        $locator->locate('whatever', $params);
  28        $this->assertTrue(false);
  29      }
  30      catch(lmbFileNotFoundException $e){}
  31    }
  32  
  33    function testLocateUsingLocations()
  34    {
  35      $locator = new lmbFileLocator($mock = new MockFileLocations());
  36  
  37      $mock->expectOnce('getLocations');
  38      $mock->setReturnValue('getLocations',
  39                            array(dirname(__FILE__) . '/design/_en/',
  40                                       dirname(__FILE__) . '/design/'));
  41  
  42      $this->assertEqual(lmbFs :: normalizePath($locator->locate('test1.html')),
  43                         lmbFs :: normalizePath(dirname(__FILE__) . '/design/_en/test1.html'));
  44    }
  45  
  46    function testSkipAbsoluteAliases()
  47    {
  48      $locator = new lmbFileLocator($mock = new MockFileLocations());
  49  
  50      $mock->expectNever('getLocations');
  51  
  52      $this->assertEqual(lmbFs :: normalizePath($locator->locate(dirname(__FILE__) . '/design/_en/test1.html')),
  53                         lmbFs :: normalizePath(dirname(__FILE__) . '/design/_en/test1.html'));
  54    }
  55  
  56    function testLocateAll()
  57    {
  58      $locator = new lmbFileLocator($mock = new MockFileLocations());
  59  
  60      $mock->expectOnce('getLocations');
  61      $mock->setReturnValue('getLocations',
  62                            array(dirname(__FILE__) . '/design/',
  63                                  dirname(__FILE__) . '/design/_en/'));
  64  
  65  
  66      $all_files = $locator->locateAll('*.html');
  67      sort($all_files);
  68      $this->assertEqual(lmbFs :: normalizePath($all_files[0]),
  69                         lmbFs :: normalizePath(dirname(__FILE__) . '/design/test1.html'));
  70  
  71      $this->assertEqual(lmbFs :: normalizePath($all_files[1]),
  72                         lmbFs :: normalizePath(dirname(__FILE__) . '/design/_en/test1.html'));
  73    }
  74  }
  75  
  76  ?>


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7