function testRegisterFromFile()
    {
        $rnd = mt_rand();
        $contents = <<<EOD
<?php
/**
 * @filter foo_{$rnd}
 * @aliases foo1_{$rnd}, foo2_{$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->setAliases(array("foo1_{$rnd}", "foo2_{$rnd}"));
        $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("foo1_{$rnd}"), $filter_info1);
        $this->assertEqual($dictionary->findFilterInfo("bar_{$rnd}"), $filter_info2);
    }
 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);
     if (isset($annotations['aliases'])) {
         $filter_aliases = explode(',', $annotations['aliases']);
         $filter_aliases = array_map('trim', $filter_aliases);
         $info->setAliases($filter_aliases);
     }
     $info->setFile($file);
     return $info;
 }
    }
}
class MacroFilterZooTest extends lmbMacroFilter
{
    function getValue()
    {
        if (!isset($this->params[0])) {
            return 'trim(' . $this->base->getValue() . ')';
        } else {
            return 'trim(' . $this->base->getValue() . ', ' . $this->params[0] . ')';
        }
    }
}
$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()
    {