[limb-svn] r6756 - in 3.x/trunk/limb: active_record/src macro/src macro/src/compiler macro/tests/cases macro/tests/cases/compiler

svn at limb-project.com svn at limb-project.com
Tue Jan 29 11:30:52 MSK 2008


Author: korchasa
Date: 2008-01-29 11:30:51 +0300 (Tue, 29 Jan 2008)
New Revision: 6756
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6756

Added:
   3.x/trunk/limb/macro/src/lmbMacroTemplateLocatorInterface.interface.php
Modified:
   3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php
   3.x/trunk/limb/macro/src/compiler/lmbMacroFilterDictionary.class.php
   3.x/trunk/limb/macro/src/compiler/lmbMacroTagDictionary.class.php
   3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php
   3.x/trunk/limb/macro/src/lmbMacroConfig.class.php
   3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
   3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php
   3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroCodeWriterTest.class.php
   3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroFilterDictionaryTest.class.php
   3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTagDictionaryTest.class.php
   3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateExecutorTest.class.php
   3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php
   3.x/trunk/limb/macro/tests/cases/lmbBaseMacroTest.class.php
Log:
 -- replace lmbActiveRecord with array

Modified: 3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php
===================================================================
--- 3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -160,7 +160,7 @@
   const ON_BEFORE_DESTROY          = 9;
   const ON_AFTER_DESTROY           = 10;
   /**#@-*/
-  
+
   /**#@+
    * Relation type constants
    */
@@ -343,7 +343,7 @@
     if(isset($this->_relations[$relation]))
       return $this->_relations[$relation];
   }
-  
+
   function getRelationType($relation)
   {
     if(isset($this->_has_one[$relation]))
@@ -371,14 +371,14 @@
                         $this->_many_belongs_to,
                         $this->_composed_of);
   }
-  
+
   protected function _getSingleObjectRelations()
   {
      return array_merge($this->_has_one,
                         $this->_belongs_to,
                         $this->_many_belongs_to,
                         $this->_composed_of);
-  }  
+  }
 
   /**
    *  Returns all relations info for one-to-many
@@ -578,7 +578,7 @@
         $this->_loadLazyAttribute($attribute);
     }
   }
-  
+
   function getLazyAttributes()
   {
     return $this->_lazy_attributes;
@@ -603,10 +603,10 @@
       $this->_loadLazyAttribute($property);
 
     if($this->_hasValueObjectRelation($property))
-    { 
+    {
       if($valueObject = $this->_getValueObject($property))
-        return $valueObject; 
-      
+        return $valueObject;
+
       return (LIMB_UNDEFINED != $default) ? $default : $valueObject;
     }
 
@@ -615,7 +615,7 @@
       return parent :: get($property);
     }
     catch(lmbNoSuchPropertyException $e) {}
-    
+
     if(LIMB_UNDEFINED != $default)
       return $default;
 
@@ -651,7 +651,7 @@
       $collection = $this->createRelationCollection($property);
       $this->_setRaw($property, $collection);
       return $collection;
-    }    
+    }
 
     throw $e;
   }
@@ -1579,7 +1579,7 @@
     else
       return $rs;
   }
-  
+
   /**
    *  Finds a collection of records(not lmbActiveRecord objects!) from database table
    *  @param string|object filtering criteria
@@ -1675,6 +1675,7 @@
     if($id = $this->_getRaw($this->_primary_key_name))
       return $id;
   }
+
   /**
    *  Sets id of an object typecasted to integer explicitly, be carefull using this method since
    *  it may break relations if used improperly

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroFilterDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroFilterDictionary.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroFilterDictionary.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -16,6 +16,7 @@
 class lmbMacroFilterDictionary
 {
   protected $info = array();
+  protected $cache_dir;
   static protected $instance;
 
   static function instance()
@@ -27,24 +28,28 @@
     return self :: $instance;
   }
 
-  function load(lmbMacroConfig $config)
+  function load($config)
   {
-    if(!$config->isForceScan() && $this->_loadCache($config))
+    if(!array_key_exists('cache_dir', $config)
+      || !array_key_exists('is_force_scan', $config)
+      || !array_key_exists('filters_scan_dirs', $config))
+      throw new lmbMacroException('Wrong Config object data', $config);
+    $this->cache_dir = $config['cache_dir'];
+    if(!$config['is_force_scan'] && $this->_loadCache())
       return;
 
-    $dirs = $config->getFiltersScanDirectories();
-    foreach($dirs as $dir)
+    foreach($config['filters_scan_dirs'] as $dir)
     {
       foreach(lmb_glob($dir . '/*.filter.php') as $file)
         $this->registerFromFile($file);
     }
 
-    $this->_saveCache($config);
+    $this->_saveCache();
   }
 
-  protected function _loadCache(lmbMacroConfig $config)
+  protected function _loadCache()
   {
-    $cache_file = $config->getCacheDir() . '/filters.cache';
+    $cache_file = $this->cache_dir . '/filters.cache';
     if(!file_exists($cache_file))
       return false;
 
@@ -57,9 +62,9 @@
     return true;
   }
 
-  protected function _saveCache(lmbMacroConfig $config)
+  protected function _saveCache()
   {
-    $cache_file = $config->getCacheDir() . '/filters.cache';
+    $cache_file = $this->cache_dir . '/filters.cache';
     lmbFs :: safeWrite($cache_file, serialize($this->info));
   }
 

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroTagDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroTagDictionary.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroTagDictionary.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -16,6 +16,7 @@
 class lmbMacroTagDictionary
 {
   protected $info = array();
+  protected $cache_dir;
   static protected $instance;
 
   static function instance()
@@ -27,27 +28,30 @@
     return self :: $instance;
   }
 
-  function load(lmbMacroConfig $config)
+  function load($config)
   {
-    if(!$config->isForceScan() && $this->_loadCache($config))
+    if(!isset($config['cache_dir']) || !$config['cache_dir']
+      || !isset($config['is_force_scan'])
+      || !isset($config['tags_scan_dirs']) || !$config['tags_scan_dirs'])      
+      throw new lmbMacroException('Wrong Config object data', $config);
+
+    $this->cache_dir = $config['cache_dir']; 
+    if(!$config['is_force_scan'] && $this->_loadCache())
       return;
-
-    $config_scan_dirs = $config->getTagsScanDirectories();
-    $real_scan_dirs = array();
-    
-    foreach($config_scan_dirs as $dir)
+      
+    $real_scan_dirs = array();    
+    foreach($config['tags_scan_dirs'] as $dir)
     {
       foreach($this->_getThisAndImmediateDirectories($dir) as $item)
         $real_scan_dirs[] = $item;
     }
-    
     foreach($real_scan_dirs as $scan_dir)
     {
       foreach(lmb_glob($scan_dir . '/*.tag.php') as $file)
         $this->registerFromFile($file);
     }
 
-    $this->_saveCache($config);
+    $this->_saveCache();
   }
 
   function _getThisAndImmediateDirectories($dir)
@@ -63,9 +67,9 @@
     return $dirs;
   }  
 
-  protected function _loadCache(lmbMacroConfig $config)
+  protected function _loadCache()
   {
-    $cache_file = $config->getCacheDir() . '/tags.cache';
+    $cache_file = $this->cache_dir . '/tags.cache';
     if(!file_exists($cache_file))
       return false;
 
@@ -78,9 +82,9 @@
     return true;
   }
 
-  protected function _saveCache(lmbMacroConfig $config)
+  protected function _saveCache()
   {
-    $cache_file = $config->getCacheDir() . '/tags.cache';
+    $cache_file = $this->cache_dir . '/tags.cache';
     lmbFs :: safeWrite($cache_file, serialize($this->info));
   }
 
@@ -119,3 +123,4 @@
   }
 }
 
+

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroTemplateExecutor.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -20,11 +20,12 @@
   protected $__config;
   protected $__context;
 
-  function __construct(lmbMacroConfig $config = null, $vars = array())
+  function __construct($config, $vars = array())
   {
-    $this->__config = $config ? $config : new lmbMacroConfig();
-    $this->setVars($vars);
+    $this->__config = $config;    
+    $this->setVars($vars);    
   }
+  
 
   //overridden in children
   protected function _init(){}

Modified: 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -13,68 +13,24 @@
  * @package macro
  * @version $Id$
  */
-class lmbMacroConfig
+class lmbMacroConfig extends lmbObject
 {
-  protected $cache_dir;
-  protected $is_force_scan;
-  protected $is_force_compile;
-  protected $tags_scan_dirs = array();
-  protected $tpl_scan_dirs = array();
-
+  public $cache_dir;
+  public $is_force_compile;
+  public $is_force_scan;
+  public $tpl_scan_dirs;
+  public $tags_scan_dirs;
+  public $filters_scan_dirs;
   function __construct($cache_dir = null, $is_force_compile = true, $is_force_scan = true,
-                       $tpl_scan_dirs = null, $tags_scan_dirs = null, $filters_scan_dirs = null)
-  {
-    $this->cache_dir = $cache_dir ? $cache_dir : LIMB_VAR_DIR . '/compiled';
-    $this->is_force_compile = $is_force_compile;
-    $this->is_force_scan = $is_force_scan;
-    $this->tpl_scan_dirs = $tpl_scan_dirs ? $tpl_scan_dirs : array('templates');
-    $this->tags_scan_dirs = $tags_scan_dirs ? $tags_scan_dirs : array('limb/macro/src/tags');
-    $this->filters_scan_dirs = $filters_scan_dirs ? $filters_scan_dirs : array('limb/macro/src/filters');
+                       $tpl_scan_dirs = array(), $tags_scan_dirs = array(), $filters_scan_dirs = array())
+  {    
+    $params['cache_dir'] = $cache_dir;
+    $params['is_force_compile'] = $is_force_compile;
+    $params['is_force_scan'] = $is_force_scan;
+    $params['tpl_scan_dirs'] = $tpl_scan_dirs;
+    $params['tags_scan_dirs'] = $tags_scan_dirs;
+    $params['filters_scan_dirs'] = $filters_scan_dirs;
+    parent::__construct($params);
   }
-
-  function getCacheDir()
-  {
-    return $this->cache_dir;
-  }
-
-  function isForceScan()
-  {
-    return $this->is_force_scan;
-  }
-
-  function isForceCompile()
-  {
-    return $this->is_force_compile;
-  }
-
-  function getTagsScanDirectories()
-  {
-    return $this->tags_scan_dirs;
-  }
-  
-  function setTagsScanDirectories($dirs)
-  {
-    $this->tags_scan_dirs = $dirs;
-  }
-
-  function getFiltersScanDirectories()
-  {
-    return $this->filters_scan_dirs;
-  }
-
-  function setFiltersScanDirectories($dirs)
-  {
-    $this->filters_scan_dirs = $dirs;
-  }
-  
-  function getTemplateScanDirectories()
-  {
-    return $this->tpl_scan_dirs;
-  }
-
-  function setTemplateScanDirectories($dirs)
-  {
-    $this->tpl_scan_dirs = $dirs;
-  }
 }
 

Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -7,8 +7,7 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
-lmb_require('limb/macro/src/lmbMacroTemplateLocator.class.php');
-lmb_require('limb/macro/src/lmbMacroConfig.class.php');
+lmb_require('limb/macro/src/lmbMacroTemplateLocatorInterface.interface.php');
 lmb_require('limb/macro/src/lmbMacroException.class.php');
 
 /**
@@ -24,13 +23,25 @@
   protected $executor;
   protected $vars = array();
   protected $child_executor;
+  public $config;
 
-  function __construct($file, lmbMacroConfig $config = null, lmbMacroTemplateLocator $locator = null)
+  function __construct($file, $config = array(), lmbMacroTemplateLocatorInterface $locator = null)
   {
     $this->file = $file;
-    $this->config = $config ? $config : new lmbMacroConfig();
+    $this->config = $config;        
+    $this->_applyConfig($config);
     $this->locator = $locator ? $locator : new lmbMacroTemplateLocator($this->config);
   }
+  
+  protected function _applyConfig($config)
+  {
+    $this->config['cache_dir'] = (isset($config['cache_dir'])) ? $config['cache_dir'] : LIMB_VAR_DIR . '/compiled';
+    $this->config['is_force_compile'] = (isset($config['is_force_compile'])) ? $config['is_force_compile'] : true;
+    $this->config['is_force_scan'] = (isset($config['is_force_scan'])) ? $config['is_force_scan'] : false;
+    $this->config['tpl_scan_dirs'] = (isset($config['tpl_scan_dirs'])) ? $config['tpl_scan_dirs'] : 'templates';
+    $this->config['tags_scan_dirs'] = (isset($config['tags_scan_dirs'])) ? $config['tags_scan_dirs'] : array('limb/macro/src/tags');
+    $this->config['filters_scan_dirs'] = (isset($config['filters_scan_dirs'])) ? $config['filters_scan_dirs'] : array('limb/macro/src/filters');    
+  }
 
   function setVars($vars)
   {
@@ -53,7 +64,7 @@
     {
       $this->compiled_file = $this->locator->locateCompiledTemplate($this->file);
 
-      if($this->config->isForceCompile() || !file_exists($this->compiled_file))
+      if($this->config['is_force_compile'] || !file_exists($this->compiled_file))
       {
         if(!$source_file = $this->locator->locateSourceTemplate($this->file))
           throw new lmbMacroException('Template source file not found', array('file_name' => $this->file));

Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -9,6 +9,7 @@
 
 lmb_require('limb/fs/toolkit.inc.php');
 lmb_require('limb/fs/src/lmbFs.class.php');
+lmb_require('limb/macro/src/lmbMacroTemplateLocatorInterface.interface.php');
 
 /**
  * class lmbMacroTemplateLocator.
@@ -16,32 +17,30 @@
  * @package macro
  * @version $Id$
  */
-class lmbMacroTemplateLocator
+class lmbMacroTemplateLocator implements lmbMacroTemplateLocatorInterface 
 {
   protected $config;
   protected $cache_dir;
   protected $scan_dirs;
   protected $toolkit;
 
-  function __construct(lmbMacroConfig $config)
+  function __construct($config)
   {
     $this->config = $config;
-    $this->cache_dir = $config->getCacheDir();
-    $this->scan_dirs = $config->getTemplateScanDirectories();
     $this->toolkit = lmbToolkit :: instance();
   }
 
   function locateSourceTemplate($file_name)
   {    
     if(!lmbFs :: isPathAbsolute($file_name))
-      return $this->toolkit->tryFindFileByAlias($file_name, $this->scan_dirs, 'macro');
+      return $this->toolkit->tryFindFileByAlias($file_name, $this->config['tpl_scan_dirs'], 'macro');
     elseif(file_exists($file_name))
       return $file_name;
   }
 
   function locateCompiledTemplate($file_name)
   {
-    return $this->cache_dir . '/' . md5($file_name) . '.php';
+    return $this->config['cache_dir'] . '/' . md5($file_name) . '.php';
   }
 }
 

Added: 3.x/trunk/limb/macro/src/lmbMacroTemplateLocatorInterface.interface.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplateLocatorInterface.interface.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplateLocatorInterface.interface.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -0,0 +1,7 @@
+<?php
+
+interface lmbMacroTemplateLocatorInterface {
+  function __construct($config);
+  function locateSourceTemplate($file_name);
+  function locateCompiledTemplate($file_name);
+}
\ No newline at end of file

Modified: 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroCodeWriterTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroCodeWriterTest.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroCodeWriterTest.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -7,12 +7,13 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
  */
 
-class lmbMacroCodeWriterTest extends UnitTestCase
+class lmbMacroCodeWriterTest extends lmbBaseMacroTest
 {
   protected $writer;
 
   function setUp()
   {
+    parent::setUp();
     $this->class = 'Foo' . mt_rand();
     $this->writer = new lmbMacroCodeWriter($this->class);
   }
@@ -140,7 +141,7 @@
   {
     $this->_writeAndInclude($this->writer->renderCode());
     $class = $this->class;
-    $object = new $class();
+    $object = new $class($this->_createMacroConfig());
     return $object;
   }
 

Modified: 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroFilterDictionaryTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroFilterDictionaryTest.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroFilterDictionaryTest.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -7,7 +7,7 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
-class lmbMacroFilterDictionaryTest extends UnitTestCase
+class lmbMacroFilterDictionaryTest extends lmbBaseMacroTest
 {
   function setUp()
   {

Modified: 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTagDictionaryTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTagDictionaryTest.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTagDictionaryTest.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -7,13 +7,13 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
-class lmbMacroTagDictionaryTest extends UnitTestCase
+class lmbMacroTagDictionaryTest extends lmbBaseMacroTest
 {
   function setUp()
-  {
-    lmbFs :: rm(LIMB_VAR_DIR . '/tags/');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/tags/');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/tags/subfolder/');
+  { 
+    parent::setUp();
+    lmbFs :: mkdir(LIMB_VAR_DIR . '/tpl/tags/');   
+    lmbFs :: mkdir(LIMB_VAR_DIR . '/tpl/tags/subfolder/');
   }
 
   function testFindTagInfo()
@@ -117,17 +117,16 @@
 class Bar{$rnd}Tag extends lmbMacroTag{}
 EOD;
 
-    file_put_contents($file1 = LIMB_VAR_DIR . '/tags/foo_' . $rnd . '.tag.php', $content1);
-    file_put_contents($file2 = LIMB_VAR_DIR . '/tags/subfolder/bar_' . $rnd . '.tag.php', $content2);
+    file_put_contents($file1 = LIMB_VAR_DIR . '/tpl/tags/foo_' . $rnd . '.tag.php', $content1);
+    file_put_contents($file2 = LIMB_VAR_DIR . '/tpl/tags/subfolder/bar_' . $rnd . '.tag.php', $content2);
 
     $tag_info1 = new lmbMacroTagInfo("foo_$rnd", "Foo{$rnd}Tag");
     $tag_info1->setFile($file1);
     $tag_info2 = new lmbMacroTagInfo("bar_$rnd", "Bar{$rnd}Tag");
-    $tag_info2->setFile($file2);
-
-    $config = new lmbMacroConfig();
-    $config->setTagsScanDirectories(array(LIMB_VAR_DIR . '/tags/'));
+    $tag_info2->setFile($file2);    
     
+    $config = $this->_createMacroConfig();
+    $config['tags_scan_dirs'] = array(LIMB_VAR_DIR . '/tpl/tags/');
     $dictionary = new lmbMacroTagDictionary();
     $dictionary->load($config);
 

Modified: 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateExecutorTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateExecutorTest.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateExecutorTest.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -7,11 +7,11 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
-class lmbMacroTemplateExecutorTest extends UnitTestCase
+class lmbMacroTemplateExecutorTest extends lmbBaseMacroTest
 {
   function testPassVars()
   {
-    $tpl = new lmbMacroTemplateExecutor(new lmbMacroConfig(), array('foo' => 'foo', 'bar' => 'bar'));
+    $tpl = new lmbMacroTemplateExecutor($this->_createMacroConfig(), array('foo' => 'foo', 'bar' => 'bar'));
     $tpl->set('zoo', 'zoo');
     $this->assertEqual($tpl->foo, 'foo');
     $this->assertEqual($tpl->bar, 'bar');
@@ -20,7 +20,7 @@
 
   function testMissingVarIsEmpty()
   {
-    $tpl = new lmbMacroTemplateExecutor(new lmbMacroConfig());
+    $tpl = new lmbMacroTemplateExecutor($this->_createMacroConfig());
     $this->assertNoErrors();
     $this->assertIdentical($tpl->junk, '');
   }

Modified: 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/tests/cases/compiler/lmbMacroTemplateTest.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -7,16 +7,8 @@
  * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
  */
  
-class lmbMacroTemplateTest extends UnitTestCase
-{
-  function setUp()
-  {
-    lmbFs :: rm(LIMB_VAR_DIR . '/view');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/view');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/view/tpl');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/view/compiled');
-  }
-
+class lmbMacroTemplateTest extends lmbBaseMacroTest
+{  
   function testRenderTemplateVar()
   {
     $view = $this->_createView('Hello, <?php echo $this->name;?>');
@@ -43,17 +35,14 @@
 
   function _createView($tpl, $config = null)
   {
-    if(!$config)
-      $config = new lmbMacroConfig(LIMB_VAR_DIR . '/view/compiled');
-
     $file = $this->_createTemplate($tpl);
-    $view = new lmbMacroTemplate($file, $config);
+    $view = new lmbMacroTemplate($file, $this->_createMacroConfig());
     return $view;
   }
 
   function _createTemplate($tpl)
   {
-    $file = LIMB_VAR_DIR . '/view/tpl/' . mt_rand() . '.phtml';
+    $file = $this->tpl_dir . mt_rand() . '.phtml';
     file_put_contents($file, $tpl);
     return $file;
   }

Modified: 3.x/trunk/limb/macro/tests/cases/lmbBaseMacroTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbBaseMacroTest.class.php	2008-01-28 15:50:58 UTC (rev 6755)
+++ 3.x/trunk/limb/macro/tests/cases/lmbBaseMacroTest.class.php	2008-01-29 08:30:51 UTC (rev 6756)
@@ -9,23 +9,36 @@
 
 class lmbBaseMacroTest extends UnitTestCase
 {
+  public $base_dir;
+  public $tpl_dir;
+  public $cache_dir;
+  public $tags_dir;
+  public $filters_dir;
+  
   function setUp()
   {
-    lmbFs :: rm(LIMB_VAR_DIR . '/tpl');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/tpl/compiled');
+    $this->base_dir = LIMB_VAR_DIR . '/tpl';
+    $this->tpl_dir = $this->base_dir.'/';      
+    $this->cache_dir = $this->base_dir . '/compiled';
+    $this->tags_dir = dirname(__FILE__).'/../../src/tags';
+    $this->filters_dir = dirname(__FILE__).'/../../src/filters';
+    
+    lmbFs :: rm($this->base_dir);
+    lmbFs :: mkdir($this->base_dir);
+    lmbFs :: mkdir($this->tpl_dir);
+    lmbFs :: mkdir($this->cache_dir);
+    lmbFs :: mkdir($this->tags_dir);
+    lmbFs :: mkdir($this->filters_dir);
   }
 
   protected function _createMacro($file)
   {
-    $base_dir = LIMB_VAR_DIR . '/tpl';
-    $cache_dir = LIMB_VAR_DIR . '/tpl/compiled';
-    $macro = new lmbMacroTemplate($file, new lmbMacroConfig($cache_dir, true, true, array($base_dir)));
-    return $macro;
+    return new lmbMacroTemplate($file, $this->_createMacroConfig());
   }
 
   protected function _createTemplate($code, $name)
   {
-    $file = LIMB_VAR_DIR . '/tpl/' . $name;
+    $file = $this->tpl_dir . $name;
     file_put_contents($file, $code);
     return $file;
   }
@@ -35,5 +48,17 @@
     $file = $this->_createTemplate($code, $name);
     return $this->_createMacro($file);
   }
-}
 
+  protected function _createMacroConfig()
+  {
+    $config = array(
+      'cache_dir' => $this->cache_dir,
+      'is_force_compile' => true,
+      'is_force_scan' => true,     
+      'tpl_scan_dirs' =>  array($this->tpl_dir),
+      'tags_scan_dirs' => array($this->tags_dir),
+      'filters_scan_dirs' => array($this->filters_dir)
+    );
+    return $config;
+  }
+}
\ No newline at end of file



More information about the limb-svn mailing list