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

svn at limb-project.com svn at limb-project.com
Mon Oct 8 00:33:16 MSD 2007


Author: serega
Date: 2007-10-08 00:33:16 +0400 (Mon, 08 Oct 2007)
New Revision: 6394
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6394

Added:
   3.x/trunk/limb/macro/src/filters/
   3.x/trunk/limb/macro/src/lmbMacroAnnotationParser.class.php
   3.x/trunk/limb/macro/src/lmbMacroAnnotationParserListener.interface.php
   3.x/trunk/limb/macro/src/lmbMacroExpressionNode.class.php
   3.x/trunk/limb/macro/src/lmbMacroFilter.class.php
   3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php
   3.x/trunk/limb/macro/src/lmbMacroFilterInfo.class.php
   3.x/trunk/limb/macro/src/lmbMacroFilterParser.class.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroAnnotationParserTest.class.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroFilterDictionaryTest.class.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroFilterParserTest.class.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroFiltersAcceptanceTest.class.php
Removed:
   3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php
Modified:
   3.x/trunk/limb/macro/src/lmbMacroCompiler.class.php
   3.x/trunk/limb/macro/src/lmbMacroConfig.class.php
   3.x/trunk/limb/macro/src/lmbMacroContentBlockAnalizerListener.class.php
   3.x/trunk/limb/macro/src/lmbMacroTagAttributeBlockAnalizerListener.class.php
   3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
   3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php
   3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
   3.x/trunk/limb/macro/src/lmbMacroTreeBuilder.class.php
   3.x/trunk/limb/macro/tests/cases/.setup.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php
   3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php
Log:
-- MACRO commit:
  * initial implementation of filters functionality. See lmbMacroFiltersAcceptanceTest for details.
  * filter_dictionary is now passed to lmbMacroCompiler
  * lmbMacroAnnotationParser extracted from lmbMacroTagInfo
  * lmbMacroConfig :: getFilterDictionary() added
  * lmbMacroTagDictionary :: register() now accepts only 1 param - tag info. File path considered to be passed to tag info already. See changes in lmbMacroTagAcceptanceTest for details.

Added: 3.x/trunk/limb/macro/src/lmbMacroAnnotationParser.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroAnnotationParser.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroAnnotationParser.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,63 @@
+<?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/core/src/lmbPHPTokenizer.class.php');
+lmb_require('limb/macro/src/lmbMacroException.class.php');
+
+/**
+ * class lmbMacroAnnotationParser.
+ *
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroAnnotationParser
+{
+  static function extractFromFile($file, $listener)
+  {
+    $infos = array();
+    $tokenizer = new lmbPHPTokenizer(file_get_contents($file));
+    while($token = $tokenizer->next())
+    {
+      if(!is_array($token))
+        continue;
+
+      //found class token
+      if($token[0] == T_CLASS)
+      {
+        //fetching class name
+        $token = $tokenizer->next();
+        $class = $token[1];
+
+        //now checking prev token for /**/
+        if(!is_array($prev_token) || $prev_token[0] != T_DOC_COMMENT)
+          throw new lmbMacroException('Invalid token, doc comment is expected');
+
+        //now parsing annotations
+        $annotations = self :: _extractAnnotations($prev_token[1]);
+        if(!$annotations)
+          throw new lmbMacroException("No annotations found in doc comment '{$prev_token[1]}' in file $file");
+
+        $infos[] = call_user_func_array (array($listener, 'createByAnnotations'), array($file, $class, $annotations));
+        //$infos[] = $listener->createByAnnotations($file, $class, $annotations);
+      }
+      $prev_token = $token;
+    }
+    return $infos;
+  }
+
+  static protected function _extractAnnotations($content)
+  {
+    if(!preg_match_all('~@(\S+)([^\n]+)?\n~', $content, $matches))
+      return false;
+    $annotations = array();
+    for($i=0;$i<count($matches[0]);$i++)
+      $annotations[trim($matches[1][$i])] = trim($matches[2][$i]);
+    return $annotations;
+  }
+}
+

Added: 3.x/trunk/limb/macro/src/lmbMacroAnnotationParserListener.interface.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroAnnotationParserListener.interface.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroAnnotationParserListener.interface.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,20 @@
+<?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
+ */
+
+/**
+ * interface lmbMacroAnnotationParserListener.
+ *
+ * @package macro
+ * @version $Id$
+ */
+interface lmbMacroAnnotationParserListener
+{
+  function createByAnnotations($class, $file, $annotations);
+}
+

Modified: 3.x/trunk/limb/macro/src/lmbMacroCompiler.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroCompiler.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroCompiler.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 lmb_require('limb/macro/src/lmbMacroTreeBuilder.class.php');
@@ -40,11 +40,19 @@
   */
   protected $tag_dictionary;
 
-  function __construct($tag_dictionary, $template_locator)
+  /**
+  * @var lmbMacroFilterDictionary
+  */
+  protected $filter_dictionary;
+
+  function __construct($tag_dictionary, $template_locator, $filter_dictionary)
   {
+    $this->tree_builder = new lmbMacroTreeBuilder($this);
+
+    $this->template_locator = $template_locator;
+
     $this->tag_dictionary = $tag_dictionary;
-    $this->template_locator = $template_locator;
-    $this->tree_builder = new lmbMacroTreeBuilder($this);
+    $this->filter_dictionary = $filter_dictionary;
   }
 
   function compile($source_file, $compiled_file, $class, $render_func)
@@ -92,9 +100,14 @@
     return $this->tag_dictionary;
   }
 
+  function getFilterDictionary()
+  {
+    return $this->filter_dictionary;
+  }
+
   static function writeFile($file, $data)
   {
-    $dirname = dirname($file);    
+    $dirname = dirname($file);
     lmbFs :: mkdir($dirname);
 
     file_put_contents($file, $data);

Modified: 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 /**
@@ -21,14 +21,15 @@
   protected $tags_scan_dirs = array();
   protected $tpl_scan_dirs = array();
 
-  function __construct($cache_dir = null, $is_force_compile = true, $is_force_scan = true, 
-                       $tpl_scan_dirs = null, $tags_scan_dirs = null)
+  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();
     $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');
   }
 
   function getCacheDir()
@@ -51,6 +52,11 @@
     return $this->tags_scan_dirs;
   }
 
+  function getFiltersScanDirectories()
+  {
+    return $this->filters_scan_dirs;
+  }
+
   function getTemplateScanDirectories()
   {
     return $this->tpl_scan_dirs;

Modified: 3.x/trunk/limb/macro/src/lmbMacroContentBlockAnalizerListener.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroContentBlockAnalizerListener.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroContentBlockAnalizerListener.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -8,7 +8,7 @@
  */
 lmb_require('limb/macro/src/lmbMacroBlockAnalizerListener.interface.php');
 lmb_require('limb/macro/src/lmbMacroOutputExpressionNode.class.php');
-lmb_require('limb/macro/src/lmbMacroExpression.class.php');
+lmb_require('limb/macro/src/lmbMacroExpressionNode.class.php');
 
 /**
  * class lmbMacroContentBlockAnalizerListener.
@@ -34,7 +34,10 @@
 
   function addExpressionFragment($text)
   {
-    $expression = new lmbMacroExpression($text);
+    $expression = new lmbMacroExpressionNode($text,
+                                             $this->tree_builder->getCursor(),
+                                             $this->tree_builder->getFilterDictionary());
+
     $output_expression = new lmbMacroOutputExpressionNode($this->location, $expression);
     $this->tree_builder->addNode($output_expression);
   }

Added: 3.x/trunk/limb/macro/src/lmbMacroExpressionNode.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroExpressionNode.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroExpressionNode.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,106 @@
+<?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/macro/src/lmbMacroExpressionInterface.interface.php');
+lmb_require('limb/macro/src/lmbMacroExpression.class.php');
+lmb_require('limb/macro/src/lmbMacroFilterParser.class.php');
+
+/**
+ * class lmbMacroExpressionNode.
+ *
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroExpressionNode  implements lmbMacroExpressionInterface
+{
+  protected $context;
+
+  protected $original_expression;
+  protected $expression;
+
+  protected $parsed;
+
+  protected $filter_dictionary;
+
+  function __construct($expression, $context_node, $filter_dictionary)
+  {
+    $this->original_expression = $expression;
+    $this->expression = $expression;
+    $this->context = $context_node;
+    $this->filter_dictionary = $filter_dictionary;
+
+    $this->_createParsedExpression();
+  }
+
+  protected function _createParsedExpression()
+  {
+    $pos = strpos($this->expression, "|");
+
+    if ($pos === FALSE)
+      $this->parsed = new lmbMacroExpression($this->expression);
+    else
+    {
+      $base_expression = trim(substr($this->expression, 0, $pos));
+      $filters_expression = trim(substr($this->expression, $pos + 1));
+      $this->parsed = $this->createFilterChain($filters_expression, new lmbMacroExpression($base_expression));
+    }
+  }
+
+  /**
+  * Parses an expression, building a chain of filters for it
+  */
+  function createFilterChain($expression, $base)
+  {
+    $filter_parser = new lmbMacroFilterParser($this->context);
+    $filters_specs = $filter_parser->parse($expression);
+
+    foreach($filters_specs as $filter_spec)
+    {
+      $filter_name = $filter_spec['name'];
+      $filter_info = $this->filter_dictionary->findFilterInfo($filter_name);
+
+      if (!is_object($filter_info))
+        $this->context->raise('Unknown filter', array('filter' => $filter_name));
+
+      $base = $this->_createFilter($filter_name, $base, $filter_spec['params']);
+    }
+
+    return $base;
+  }
+
+  protected function _createFilter($name, $base, $params = "")
+  {
+    $filter_info = $this->filter_dictionary->findFilterInfo($name);
+
+    if (!is_object($filter_info))
+      $this->context->raise('Unknown filter', array('filter' => $name));
+
+    $filter_info->load();
+
+    $filter_class = $filter_info->getClass();
+    $filter = new $filter_class($base);
+    return $filter;
+  }
+
+  function getValue()
+  {
+    return $this->parsed->getValue();
+  }
+
+  function preGenerate($code_writer)
+  {
+    $this->parsed->preGenerate($code_writer);
+  }
+
+  function getFilterDictionary()
+  {
+    return $this->filter_dictionary;
+  }
+}
+

Added: 3.x/trunk/limb/macro/src/lmbMacroFilter.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroFilter.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroFilter.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,37 @@
+<?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/macro/src/lmbMacroExpressionInterface.interface.php');
+
+/**
+ * class lmbMacroFilter
+ * @package macro
+ * @version $Id$
+ */
+abstract class lmbMacroFilter implements lmbMacroExpressionInterface
+{
+  protected $base;
+  protected $params;
+
+  function __construct($base)
+  {
+    $this->base = $base;
+  }
+
+  function preGenerate($code)
+  {
+    $this->base->preGenerate($code);
+  }
+
+  function setParams($params)
+  {
+    $this->params = $params;
+  }
+}
+

Added: 3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,72 @@
+<?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/macro/src/lmbMacroFilterInfo.class.php');
+lmb_require('limb/macro/src/lmbMacroAnnotationParser.class.php');
+
+/**
+ * class lmbMacroFilterDictionary.
+ *
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroFilterDictionary
+{
+  protected $info = array();
+  protected $output_filter_info;
+  static protected $instance;
+
+  static function instance()
+  {
+    if(self :: $instance)
+      return self :: $instance;
+
+    self :: $instance = new lmbMacroFilterDictionary();
+    return self :: $instance;
+  }
+
+  static function load(lmbMacroConfig $config)
+  {
+    $dictionary = self :: instance();
+
+    $dirs = $config->getFiltersScanDirectories();
+    foreach($dirs as $dir)
+    {
+      foreach(lmb_glob($dir . '/*.tag.php') as $file)
+        $dictionary->registerFromFile($file);
+    }
+
+    return $dictionary;
+  }
+
+  function register($filter_info)
+  {
+    $name_to_lower = strtolower($filter_info->getName());
+
+    if(isset($this->info[$name_to_lower]))
+      return;
+
+    $this->info[$name_to_lower] = $filter_info;
+  }
+
+  function registerFromFile($file)
+  {
+    $infos = lmbMacroAnnotationParser :: extractFromFile($file, 'lmbMacroFilterInfo');
+    foreach($infos as $info)
+      $this->register($info, $file);
+  }
+
+  function findFilterInfo($name)
+  {
+    $name = strtolower($name);
+    if(isset($this->info[$name]))
+      return $this->info[$name];
+  }
+}
+

Added: 3.x/trunk/limb/macro/src/lmbMacroFilterInfo.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroFilterInfo.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroFilterInfo.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,67 @@
+<?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
+ */
+
+/**
+ * class lmbMacroFilterInfo.
+ *
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroFilterInfo
+{
+  protected $name = '';
+  protected $class = '';
+  protected $file;
+
+  function __construct($name, $class)
+  {
+    $this->name = $name;
+    $this->class = $class;
+  }
+
+  static function createByAnnotations($file, $class, $annotations)
+  {
+    if(!isset($annotations['filter']))
+      throw new lmbMacroException("@filter annotation is missing for class '$class'");
+
+    $filter = $annotations['filter'];
+    $info = new lmbMacroFilterInfo($filter, $class);
+
+    $info->setFile($file);
+
+    return $info;
+  }
+
+  function load()
+  {
+    if (!class_exists($this->class) && isset($this->file))
+        require_once $this->file;
+  }
+
+  function getName()
+  {
+    return $this->name;
+  }
+
+  function getClass()
+  {
+    return $this->class;
+  }
+
+  function setFile($file)
+  {
+    $this->file = $file;
+  }
+
+  function getFile()
+  {
+    return $this->file;
+  }
+}
+

Added: 3.x/trunk/limb/macro/src/lmbMacroFilterParser.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroFilterParser.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/src/lmbMacroFilterParser.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,138 @@
+<?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
+ */
+
+/**
+ * class lmbMacroFilterParser.
+ *
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroFilterParser
+{
+  protected $text;
+  protected $position;
+  protected $length;
+  protected $context;
+  protected $filters = array();
+
+  /**
+  * Construct this parser
+  */
+  function __construct($context)
+  {
+    $this->context = $context;
+  }
+
+  protected function getToken($pattern)
+  {
+    if (preg_match($pattern, $this->text, $match, PREG_OFFSET_CAPTURE, $this->position))
+    {
+      $this->position += strlen($match[0][0]);
+      return $match[1][0];
+    }
+    else
+      return FALSE;
+  }
+
+  function getFilters()
+  {
+    return $this->filters;
+  }
+
+  /**
+  * Parse text for expressions and emit a stream of events for expression fragments
+  */
+  function parse($text)
+  {
+    if (strlen($text) == 0)
+      return array();
+
+    $filters = array();
+
+    $this->text = $text;
+    $this->position = 0;
+
+    $filters_expressions = $this->_extractFiltersExpressions();
+
+    foreach($filters_expressions as $filter_expression)
+    {
+      $result = preg_match('/\G\s*([A-Za-z][A-Za-z0-9_.]*)/u', $filter_expression, $match, PREG_OFFSET_CAPTURE);
+
+      if(!$result)
+         $this->context->raise('Filter name expected');
+
+      $position = $match[0][1];
+      $filter_name = $match[1][0];
+      $filters[$filter_name] = array('name' => $filter_name,
+                                     'expression' => $filter_expression,
+                                     'params' => "");
+
+      $params_expression = substr($filter_expression, strlen($filter_name));
+      if(!$params_expression)
+        continue;
+
+      if(strlen($params_expression))
+      {
+        $params_start_position = strpos($params_expression, ':');
+        if(($params_start_position === FALSE))
+          $this->context->raise('Unexpected symbol after filter name');
+      }
+
+      $params = substr($params_expression, $params_start_position + 1);
+      if (strlen($params) == 0)
+        $this->context->raise('Filter params expected after ":" symbol');
+
+      $filters[$filter_name]['params'] = $params;
+    }
+
+    return $filters;
+  }
+
+  protected function _extractFiltersExpressions()
+  {
+    $length = strlen($this->text);
+    $this->position = 0;
+
+    $filters_expressions = array();
+    do
+    {
+      $token = $this->getToken('/\G("|\'|\||[^\'"\|]+)/u');
+      if ($token === FALSE)
+      {
+        $filters_expressions[] = $this->text;
+        break;
+      }
+
+      if ($token == '"' || $token == "'")
+      {
+        $string = $this->getToken('/\G([^' . $token . ']*)' . $token . ',?/u');
+
+        if ($string === FALSE)
+          $this->context->raise("Expecting a string literal in filter param");
+      }
+      elseif($token == '|')
+      {
+        $filters_expressions[] = substr($this->text, 0, $this->position - 1);
+        $this->text = substr($this->text, $this->position);
+        $length = strlen($this->text);
+        $this->position = 0;
+      }
+    }
+    while($this->position < $length);
+
+    //ensures the last filter expression added
+    $filters_expressions[] = substr($this->text, 0, $this->position );
+    $this->text = substr($this->text, $this->position);
+    $length = strlen($this->text);
+    $this->position = 0;
+
+    return $filters_expressions;
+  }
+}
+

Modified: 3.x/trunk/limb/macro/src/lmbMacroTagAttributeBlockAnalizerListener.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagAttributeBlockAnalizerListener.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagAttributeBlockAnalizerListener.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -8,6 +8,7 @@
  */
 
 lmb_require('limb/macro/src/lmbMacroBlockAnalizerListener.interface.php');
+lmb_require('limb/macro/src/lmbMacroExpression.class.php');
 /**
  * class lmbMacroTagAttributeBlockAnalizerListener.
  *

Modified: 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -8,6 +8,7 @@
  */
 
 lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
+lmb_require('limb/macro/src/lmbMacroAnnotationParser.class.php');
 
 /**
  * class lmbMacroTagDictionary.
@@ -44,20 +45,19 @@
     return $dictionary;
   }
 
-  function register($taginfo, $file)
+  function register($taginfo)
   {
     $tag_to_lower = strtolower($taginfo->getTag());
 
     if(isset($this->info[$tag_to_lower]))
       return;
 
-    $taginfo->setFile($file);
     $this->info[$tag_to_lower] = $taginfo;
   }
 
   function registerFromFile($file)
   {
-    $infos = lmbMacroTagInfo :: extractFromFile($file);
+    $infos = lmbMacroAnnotationParser :: extractFromFile($file, 'lmbMacroTagInfo');
     foreach($infos as $info)
       $this->register($info, $file);
   }

Modified: 3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/core/src/lmbPHPTokenizer.class.php');
 lmb_require('limb/macro/src/lmbMacroException.class.php');
@@ -32,62 +32,22 @@
     $this->require_endtag = $require_endtag;
   }
 
-  static function extractFromFile($file)
+  static function createByAnnotations($file, $class, $annotations)
   {
-    $infos = array();
-    $tokenizer = new lmbPHPTokenizer(file_get_contents($file));
-    while($token = $tokenizer->next())
-    {
-      if(!is_array($token))
-        continue;
-
-      //found class token
-      if($token[0] == T_CLASS)
-      {
-        //fetching class name
-        $token = $tokenizer->next();
-        $class = $token[1]; 
-
-        //now checking prev token for /**/
-        if(!is_array($prev_token) || $prev_token[0] != T_DOC_COMMENT)
-          throw new lmbMacroException('Invalid token, doc comment is expected');
-
-        //now parsing annotations
-        $annotations = self :: _extractAnnotations($prev_token[1]);
-        if(!$annotations)
-          throw new lmbMacroException("No annotations found in doc comment '{$prev_token[1]}' in file $file");
-
-        $infos[] = self :: createByAnnotations($class, $annotations);
-      }
-      $prev_token = $token;
-    }
-    return $infos;
-  }
-
-  static function createByAnnotations($class, $annotations)
-  {
     if(!isset($annotations['tag']))
       throw new lmbMacroException("@tag annotation is missing for class '$class'");
 
     $tag = $annotations['tag'];
     $info = new lmbMacroTagInfo($tag, $class);
 
+    $info->setFile($file);
+
     if(isset($annotations['endtag']) && $annotations['endtag'] == 'no')
       $info->setForbidEndtag(true);
 
     return $info;
   }
 
-  static protected function _extractAnnotations($content)
-  {
-    if(!preg_match_all('~@(\S+)([^\n]+)?\n~', $content, $matches))
-      return false;
-    $annotations = array();
-    for($i=0;$i<count($matches[0]);$i++)
-      $annotations[trim($matches[1][$i])] = trim($matches[2][$i]);
-    return $annotations;
-  }
-  
   function getTag()
   {
     return $this->tag;
@@ -97,7 +57,7 @@
   {
     return $this->class;
   }
-  
+
   function setFile($file)
   {
     $this->file = $file;

Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -2,14 +2,15 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 lmb_require('limb/macro/src/lmbMacroTemplateLocator.class.php');
 lmb_require('limb/macro/src/lmbMacroCompiler.class.php');
 lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmb_require('limb/macro/src/lmbMacroFilterDictionary.class.php');
 lmb_require('limb/macro/src/lmbMacroConfig.class.php');
 
 /**
@@ -59,7 +60,7 @@
 
     if($this->config->isForceCompile() || !file_exists($compiled_file))
     {
-      if(!$source_file = $this->locator->locateSourceTemplate($this->file))    
+      if(!$source_file = $this->locator->locateSourceTemplate($this->file))
         throw new lmbMacroException('Template source file not found', array('file_name' => $this->file));
 
       $macro_executor_class = 'MacroTemplateExecutor' . uniqid();//think about evaling this instance
@@ -67,7 +68,7 @@
       $compiler = $this->_createCompiler();
       $compiler->compile($source_file, $compiled_file, $macro_executor_class, 'render');
       //appending macro executor class
-      file_put_contents($compiled_file, file_get_contents($compiled_file) . 
+      file_put_contents($compiled_file, file_get_contents($compiled_file) .
                                         "\n\$macro_executor_class='$macro_executor_class';");
     }
 
@@ -88,7 +89,8 @@
   protected function _createCompiler()
   {
     $tag_dictionary = lmbMacroTagDictionary :: load($this->config);
-    return new lmbMacroCompiler($tag_dictionary, $this->locator);
+    $filter_dictionary = lmbMacroFilterDictionary :: load($this->config);
+    return new lmbMacroCompiler($tag_dictionary, $this->locator, $filter_dictionary);
   }
 }
 

Modified: 3.x/trunk/limb/macro/src/lmbMacroTreeBuilder.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTreeBuilder.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/src/lmbMacroTreeBuilder.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -32,6 +32,7 @@
   protected $compiler;
   protected $node;
 
+  protected $filter_dictionary;
   /**
   * Stack of tags pushed onto the tree builder
   */
@@ -86,7 +87,7 @@
 
   function addContent($text, $location)
   {
-    $listener = new lmbMacroContentBlockAnalizerListener($this, $location);
+    $listener = new lmbMacroContentBlockAnalizerListener($this, $location, $this->filter_dictionary);
     $analizer = new lmbMacroBlockAnalizer();
     $analizer->parse($text, $listener);
   }
@@ -182,5 +183,10 @@
     $item = end($this->expected_tags);
     return $item[1];
   }
+
+  function getFilterDictionary()
+  {
+    return $this->compiler->getFilterDictionary();
+  }
 }
 

Modified: 3.x/trunk/limb/macro/tests/cases/.setup.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/.setup.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/tests/cases/.setup.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -1,4 +1,5 @@
 <?php
 require_once(dirname(__FILE__) . '/../../common.inc.php');
 require_once(dirname(__FILE__) . '/lmbBaseMacroTest.class.php');
+lmb_require('limb/fs/src/lmbFs.class.php');
 

Added: 3.x/trunk/limb/macro/tests/cases/lmbMacroAnnotationParserTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroAnnotationParserTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroAnnotationParserTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,66 @@
+<?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');
+lmb_require('limb/macro/src/lmbMacroAnnotationParser.class.php');
+lmb_require('limb/macro/src/lmbMacroAnnotationParserListener.interface.php');
+
+Mock :: generate('lmbMacroAnnotationParserListener', 'MockMacroAnnotationParserListener');
+
+class lmbMacroAnnotationParserTest extends UnitTestCase
+{
+  function setUp()
+  {
+    lmbFs :: rm(LIMB_VAR_DIR . '/tags/');
+    lmbFs :: mkdir(LIMB_VAR_DIR . '/tags/');
+  }
+
+  function testExtractOneFromFile()
+  {
+    $rnd = mt_rand();
+    $contents = <<<EOD
+<?php
+/**
+ * @tag foo_{$rnd}
+ */
+class Foo{$rnd}Tag extends lmbMacroTag{}
+EOD;
+    file_put_contents($file = LIMB_VAR_DIR . '/tags/' . $rnd . '.tag.php', $contents);
+
+    $listener = new MockMacroAnnotationParserListener();
+    $listener->expectOnce('createByAnnotations', array($file, "Foo{$rnd}Tag", array('tag' => "foo_{$rnd}")));
+    $info = lmbMacroAnnotationParser :: extractFromFile($file, $listener);
+  }
+
+  function testExtractSeveralFromFile()
+  {
+    $rnd = mt_rand();
+    $contents = <<<EOD
+<?php
+/**
+ * @tag foo_{$rnd}
+ */
+class Foo{$rnd}Tag extends lmbMacroTag{}
+
+/**
+ * @tag bar_{$rnd}
+ */
+class Bar{$rnd}Tag extends lmbMacroTag{}
+EOD;
+    file_put_contents($file = LIMB_VAR_DIR . '/tags/' . $rnd . '.tag.php', $contents);
+
+    $listener = new MockMacroAnnotationParserListener();
+    $listener->expectCallCount('createByAnnotations', 2);
+    $listener->expectArgumentsAt(0, 'createByAnnotations', array($file, "Foo{$rnd}Tag", array('tag' => "foo_{$rnd}")));
+    $listener->expectArgumentsAt(1, 'createByAnnotations', array($file, "Bar{$rnd}Tag", array('tag' => "bar_{$rnd}")));
+
+    $info = lmbMacroAnnotationParser :: extractFromFile($file, $listener);
+  }
+}
+

Added: 3.x/trunk/limb/macro/tests/cases/lmbMacroFilterDictionaryTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroFilterDictionaryTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroFilterDictionaryTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,81 @@
+<?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');
+lmb_require('limb/macro/src/lmbMacroFilter.class.php');
+lmb_require('limb/macro/src/lmbMacroFilterInfo.class.php');
+lmb_require('limb/macro/src/lmbMacroFilterDictionary.class.php');
+
+class lmbMacroFilterDictionaryTest extends UnitTestCase
+{
+  function setUp()
+  {
+    lmbFs :: rm(LIMB_VAR_DIR . '/filters/');
+    lmbFs :: mkdir(LIMB_VAR_DIR . '/filters/');
+  }
+
+  function testFindFilterInfo()
+  {
+    $filter_info = new lmbMacroFilterInfo('testtag', 'SomeFilterClass');
+    $dictionary = new lmbMacroFilterDictionary();
+    $dictionary->register($filter_info, $file = 'whatever');
+
+    $this->assertIsA($dictionary->findFilterInfo('testtag'), 'lmbMacroFilterInfo');
+  }
+
+  function testRegisterFilterInfoOnceOnly()
+  {
+    $dictionary = new lmbMacroFilterDictionary();
+    $filter_info1 = new lmbMacroFilterInfo('some_filter', 'SomeFilterClass');
+    $filter_info2 = new lmbMacroFilterInfo('some_filter', 'SomeFilterClass');
+    $dictionary->register($filter_info1, $file1 = 'whatever1');
+    $dictionary->register($filter_info2, $file2 = 'whatever2');
+
+    $this->assertEqual($dictionary->findFilterInfo('some_filter'), $filter_info1);
+  }
+
+  function testFilterNotFound()
+  {
+    $filter_info = new lmbMacroFilterInfo('testtag', 'SomeFilterClass');
+    $dictionary = new lmbMacroFilterDictionary();
+    $dictionary->register($filter_info, $file = 'whatever');
+
+    $this->assertFalse($dictionary->findFilterInfo('junk'));
+  }
+
+  function testRegisterFromFile()
+  {
+    $rnd = mt_rand();
+    $contents = <<<EOD
+<?php
+/**
+ * @filter foo_{$rnd}
+ */
+class Foo{$rnd}Filter extends lmbMacroFilter{}
+
+/**
+ * @filter bar_{$rnd}
+ */
+class Bar{$rnd}Filter extends lmbMacroFilter{}
+EOD;
+    file_put_contents($file = LIMB_VAR_DIR . '/filters/' . $rnd . '.filter.php', $contents);
+
+    $filter_info1 = new lmbMacroFilterInfo("foo_$rnd", "Foo{$rnd}Filter");
+    $filter_info1->setFile($file);
+    $filter_info2 = new lmbMacroFilterInfo("bar_$rnd", "Bar{$rnd}Filter");
+    $filter_info2->setFile($file);
+
+    $dictionary = new lmbMacroFilterDictionary();
+    $dictionary->registerFromFile($file);
+
+    $this->assertEqual($dictionary->findFilterInfo("foo_$rnd"), $filter_info1);
+    $this->assertEqual($dictionary->findFilterInfo("bar_$rnd"), $filter_info2);
+  }
+}
+

Added: 3.x/trunk/limb/macro/tests/cases/lmbMacroFilterParserTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroFilterParserTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroFilterParserTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,136 @@
+<?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/macro/src/lmbMacroFilterParser.class.php');
+lmb_require('limb/macro/src/lmbMacroSourceLocation.class.php');
+lmb_require('limb/macro/src/lmbMacroNode.class.php');
+
+class lmbMacroFilterParserTest extends UnitTestCase
+{
+  protected $parser;
+
+  function setUp()
+  {
+    $location = new lmbMacroSourceLocation('my_testing_file', 10);
+    $context_node = new lmbMacroNode($location);
+
+    $this->parser = new lmbMacroFilterParser($context_node);
+  }
+
+  function testName()
+  {
+    $filters = $this->parser->parse($expression = 'filter');
+    $this->assertEqual($filters, array('filter' => array('name' => 'filter',
+                                                         'expression' => 'filter',
+                                                         'params' => "")));
+  }
+
+  function testEmptyName()
+  {
+    $filters = $this->parser->parse($expression = '');
+    $this->assertEqual($filters, array());
+  }
+
+  function testInvalidName()
+  {
+    try
+    {
+      $filters = $this->parser->parse($expression = '"filter"');
+      $this->assertTrue(false);
+    }
+    catch(Exception $e)
+    {
+      $this->assertWantedPattern('/Filter name expected/', $e->getMessage());
+    }
+  }
+
+  function testNoArgsWithDelimiter()
+  {
+    try
+    {
+      $filters = $this->parser->parse($expression = 'filter:');
+      $this->assertTrue(false);
+    }
+    catch(Exception $e)
+    {
+      $this->assertWantedPattern('/Filter params expected after ":" symbol/', $e->getMessage());
+    }
+  }
+
+  function testNoArgsWithComma()
+  {
+    try
+    {
+      $filters = $this->parser->parse($expression = 'filter,');
+      $this->assertTrue(false);
+    }
+    catch(Exception $e)
+    {
+      $this->assertWantedPattern('/Unexpected symbol after filter name/', $e->getMessage());
+    }
+  }
+
+  function testOneParam()
+  {
+    $filters = $this->parser->parse($expression = 'filter:$arg');
+    $this->assertEqual($filters, array('filter' => array('name' => 'filter',
+                                                         'expression' => 'filter:$arg',
+                                                         'params' => '$arg')));
+  }
+
+  function testTwoParams()
+  {
+    $filters = $this->parser->parse($expression = 'filter:$arg1,"arg2"');
+    $this->assertEqual($filters, array('filter' => array('name' => 'filter',
+                                                         'expression' => 'filter:$arg1,"arg2"',
+                                                         'params' => '$arg1,"arg2"')));
+  }
+
+  function testSpaceInParams()
+  {
+    $filters = $this->parser->parse($expression = 'filter:" "');
+    $this->assertEqual($filters, array('filter' => array('name' => 'filter',
+                                                         'expression' => 'filter:" "',
+                                                         'params' => '" "')));
+  }
+
+  function testTwoFiltersNoParams()
+  {
+    $filters = $this->parser->parse($expression = 'filter1|filter2');
+    $this->assertEqual($filters, array('filter1' => array('name' => 'filter1',
+                                                         'expression' => 'filter1',
+                                                         'params' => ''),
+                                       'filter2' => array('name' => 'filter2',
+                                                         'expression' => 'filter2',
+                                                         'params' => '')));
+  }
+
+  function testTwoFiltersWithParams()
+  {
+    $filters = $this->parser->parse($expression = 'filter1: $arg1, arg2 |filter2: arg3');
+    $this->assertEqual($filters, array('filter1' => array('name' => 'filter1',
+                                                         'expression' => 'filter1: $arg1, arg2 ',
+                                                         'params' => ' $arg1, arg2 '),
+                                       'filter2' => array('name' => 'filter2',
+                                                         'expression' => 'filter2: arg3',
+                                                         'params' => ' arg3')));
+  }
+
+  function testTwoFiltersWithSeparatorInParams()
+  {
+    $filters = $this->parser->parse($expression = 'filter1: "x|y", arg2 |filter2: arg3');
+    $this->assertEqual($filters, array('filter1' => array('name' => 'filter1',
+                                                         'expression' => 'filter1: "x|y", arg2 ',
+                                                         'params' => ' "x|y", arg2 '),
+                                       'filter2' => array('name' => 'filter2',
+                                                         'expression' => 'filter2: arg3',
+                                                         'params' => ' arg3')));
+  }
+}
+

Added: 3.x/trunk/limb/macro/tests/cases/lmbMacroFiltersAcceptanceTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroFiltersAcceptanceTest.class.php	                        (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroFiltersAcceptanceTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -0,0 +1,62 @@
+<?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/macro/src/lmbMacroTemplate.class.php');
+lmb_require('limb/macro/src/lmbMacroConfig.class.php');
+lmb_require('limb/macro/src/lmbMacroFilter.class.php');
+lmb_require('limb/macro/src/lmbMacroFilterInfo.class.php');
+lmb_require('limb/macro/src/lmbMacroFilterDictionary.class.php');
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
+lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+
+class MacroFilterFooTest extends lmbMacroFilter
+{
+  function getValue()
+  {
+    return 'strtoupper(' . $this->base->getValue() . ')';
+  }
+}
+
+class MacroFilterZooTest extends lmbMacroFilter
+{
+  function getValue()
+  {
+    return 'trim(' . $this->base->getValue() . ')';
+  }
+}
+
+$foo_filter_info = new lmbMacroFilterInfo('uppercase', 'MacroFilterFooTest');
+$foo_filter_info->setFile(__FILE__);
+$zoo_filter_info = new lmbMacroFilterInfo('trim', 'MacroFilterZooTest');
+$zoo_filter_info->setFile(__FILE__);
+
+lmbMacroFilterDictionary :: instance()->register($foo_filter_info);
+lmbMacroFilterDictionary :: instance()->register($zoo_filter_info);
+
+class lmbMacroFiltersTest extends lmbBaseMacroTest
+{
+  function testFilter()
+  {
+    $code = '{$#var|uppercase}';
+    $tpl = $this->_createMacroTemplate($code, 'tpl.html');
+    $tpl->set('var', 'hello');
+    $out = $tpl->render();
+    $this->assertEqual($out, 'HELLO');
+  }
+
+  function testFilterChain()
+  {
+    $code = '{$#var|trim|uppercase}';
+    $tpl = $this->_createMacroTemplate($code, 'tpl.html');
+    $tpl->set('var', '  hello  ');
+    $out = $tpl->render();
+    $this->assertEqual($out, 'HELLO');
+  }
+}
+

Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -39,12 +39,15 @@
 }
 
 $foo_info = new lmbMacroTagInfo('foo', 'MacroTagFooTest');
+$foo_info->setFile(__FILE__);
 $bar_info = new lmbMacroTagInfo('bar', 'MacroTagBarTest');
+$bar_info->setFile(__FILE__);
 $zoo_info = new lmbMacroTagInfo('zoo', 'MacroTagZooTest');
+$zoo_info->setFile(__FILE__);
 
-lmbMacroTagDictionary :: instance()->register($foo_info, __FILE__);
-lmbMacroTagDictionary :: instance()->register($bar_info, __FILE__);
-lmbMacroTagDictionary :: instance()->register($zoo_info, __FILE__);
+lmbMacroTagDictionary :: instance()->register($foo_info);
+lmbMacroTagDictionary :: instance()->register($bar_info);
+lmbMacroTagDictionary :: instance()->register($zoo_info);
 
 class lmbMacroTagAcceptanceTest extends lmbBaseMacroTest
 {

Deleted: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -1,63 +0,0 @@
-<?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');
-lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
-
-class lmbMacroTagInfoTest extends UnitTestCase
-{
-  function setUp()
-  {
-    lmbFs :: rm(LIMB_VAR_DIR . '/tags/');
-    lmbFs :: mkdir(LIMB_VAR_DIR . '/tags/');
-  }
-
-  function testExtractOneFromFile()
-  {
-    $rnd = mt_rand();
-    $contents = <<<EOD
-<?php
-/**
- * @tag foo_{$rnd}
- */
-class Foo{$rnd}Tag extends lmbMacroTag{}
-EOD;
-    file_put_contents($file = LIMB_VAR_DIR . '/tags/' . $rnd . '.tag.php', $contents);
-
-    $info = lmbMacroTagInfo :: extractFromFile($file);
-
-    $this->assertEqual(sizeof($info), 1);
-    $this->assertEqual($info[0], new lmbMacroTagInfo("foo_$rnd", "Foo{$rnd}Tag"));
-  }
-
-  function testExtractSeveralFromFile()
-  {
-    $rnd = mt_rand();
-    $contents = <<<EOD
-<?php
-/**
- * @tag foo_{$rnd}
- */
-class Foo{$rnd}Tag extends lmbMacroTag{}
-
-/**
- * @tag bar_{$rnd}
- */
-class Bar{$rnd}Tag extends lmbMacroTag{}
-EOD;
-    file_put_contents($file = LIMB_VAR_DIR . '/tags/' . $rnd . '.tag.php', $contents);
-
-    $info = lmbMacroTagInfo :: extractFromFile($file);
-
-    $this->assertEqual(sizeof($info), 2);
-    $this->assertEqual($info[0], new lmbMacroTagInfo("foo_$rnd", "Foo{$rnd}Tag"));
-    $this->assertEqual($info[1], new lmbMacroTagInfo("bar_$rnd", "Bar{$rnd}Tag"));
-  }
-}
-

Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php	2007-10-07 07:54:55 UTC (rev 6393)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php	2007-10-07 20:33:16 UTC (rev 6394)
@@ -2,12 +2,13 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
-lmb_require('limb/macro/src/lmbMacroTemplateExecutor.class.php'); 
+lmb_require('limb/macro/src/lmbMacroTemplateExecutor.class.php');
+lmb_require('limb/macro/src/lmbMacroConfig.class.php');
 
 class lmbMacroTemplateExecutorTest extends UnitTestCase
 {



More information about the limb-svn mailing list