[limb-svn] r6318 - in 3.x/trunk/limb/macro: src src/tags tests/cases tests/cases/tags
svn at limb-project.com
svn at limb-project.com
Thu Sep 20 01:30:30 MSD 2007
Author: pachanga
Date: 2007-09-20 01:30:30 +0400 (Thu, 20 Sep 2007)
New Revision: 6318
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6318
Modified:
3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php
3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php
3.x/trunk/limb/macro/src/tags/include.tag.php
3.x/trunk/limb/macro/src/tags/into.tag.php
3.x/trunk/limb/macro/src/tags/slot.tag.php
3.x/trunk/limb/macro/src/tags/wrap.tag.php
3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php
3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
Log:
-- switching to new tags registration schema in tests
Modified: 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -40,6 +40,13 @@
$this->info[$tag_to_lower] = $taginfo;
}
+ function registerFromFile($file)
+ {
+ $infos = lmbMacroTagInfo :: extractFromFile($file);
+ foreach($infos as $info)
+ $this->register($info, $file);
+ }
+
function findTagInfo($tag)
{
$tag = strtolower($tag);
Modified: 3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagInfo.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -59,17 +59,17 @@
$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'];
- return new lmbMacroTagInfo($class, $tag);
+ return new lmbMacroTagInfo($tag, $class);
}
static protected function _extractAnnotations($content)
@@ -97,6 +97,11 @@
$this->file = $file;
}
+ function getFile()
+ {
+ return $this->file;
+ }
+
function setForbidEndtag($flag = true)
{
$this->require_endtag = !$flag;
Modified: 3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -116,6 +116,7 @@
protected function _createTagNode($tag_info, $tag)
{
$class = $tag_info->getClass();
+ require_once($tag_info->getFile());
$tag_node = new $class($this->parser->getCurrentLocation(), $tag, $tag_info);
return $tag_node;
}
Modified: 3.x/trunk/limb/macro/src/tags/include.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/include.tag.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/tags/include.tag.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -7,16 +7,12 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
-//temporary includes, make it more flexible later
-lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
lmb_require('limb/macro/src/lmbMacroTag.class.php');
-lmbMacroTagDictionary :: instance()->register(new lmbMacroTagInfo('include', 'lmbMacroIncludeTag', false), __FILE__);
-
/**
* class lmbMacroIncludeTag.
*
+ * @tag include
* @package macro
* @version $Id$
*/
Modified: 3.x/trunk/limb/macro/src/tags/into.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/into.tag.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/tags/into.tag.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -7,16 +7,12 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
-//temporary includes, make it more flexible later
-lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
lmb_require('limb/macro/src/lmbMacroTag.class.php');
-lmbMacroTagDictionary :: instance()->register(new lmbMacroTagInfo('into', 'lmbMacroIntoTag'), __FILE__);
-
/**
* class lmbMacroIntoTag.
*
+ * @tag into
* @package macro
* @version $Id$
*/
Modified: 3.x/trunk/limb/macro/src/tags/slot.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/slot.tag.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/tags/slot.tag.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -7,16 +7,12 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
-//temporary includes, make it more flexible later
-lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
lmb_require('limb/macro/src/lmbMacroTag.class.php');
-lmbMacroTagDictionary :: instance()->register(new lmbMacroTagInfo('slot', 'lmbMacroSlotTag'), __FILE__);
-
/**
* class lmbMacroSlotTag.
*
+ * @tag slot
* @package macro
* @version $Id$
*/
Modified: 3.x/trunk/limb/macro/src/tags/wrap.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/wrap.tag.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/src/tags/wrap.tag.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -7,16 +7,12 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
-//temporary includes, make it more flexible later
-lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
lmb_require('limb/macro/src/lmbMacroTag.class.php');
-lmbMacroTagDictionary :: instance()->register(new lmbMacroTagInfo('wrap', 'lmbMacroWrapTag', true), __FILE__);
-
/**
* class lmbMacroWrapTag.
*
+ * @tag wrap
* @package macro
* @version $Id$
*/
Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -7,6 +7,7 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
+lmb_require('limb/fs/src/lmbFs.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');
@@ -48,7 +49,7 @@
$this->assertFalse($dictionary->findTagInfo('junk'));
}
- function _testRegisterFromFile()
+ function testRegisterFromFile()
{
$rnd = mt_rand();
$contents = <<<EOD
@@ -66,7 +67,9 @@
file_put_contents($file = LIMB_VAR_DIR . '/tags/' . $rnd . '.tag.php', $contents);
$tag_info1 = new lmbMacroTagInfo("foo_$rnd", "Foo{$rnd}Tag");
+ $tag_info1->setFile($file);
$tag_info2 = new lmbMacroTagInfo("bar_$rnd", "Bar{$rnd}Tag");
+ $tag_info2->setFile($file);
$dictionary = new lmbMacroTagDictionary();
$dictionary->registerFromFile($file);
Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagInfoTest.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -33,7 +33,7 @@
$info = lmbMacroTagInfo :: extractFromFile($file);
$this->assertEqual(sizeof($info), 1);
- $this->assertEqual($info[0], new lmbMacroTagInfo("Foo{$rnd}Tag", "foo_$rnd"));
+ $this->assertEqual($info[0], new lmbMacroTagInfo("foo_$rnd", "Foo{$rnd}Tag"));
}
function testExtractSeveralFromFile()
@@ -56,8 +56,8 @@
$info = lmbMacroTagInfo :: extractFromFile($file);
$this->assertEqual(sizeof($info), 2);
- $this->assertEqual($info[0], new lmbMacroTagInfo("Foo{$rnd}Tag", "foo_$rnd"));
- $this->assertEqual($info[1], new lmbMacroTagInfo("Bar{$rnd}Tag", "bar_$rnd"));
+ $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/tags/lmbMacroIncludeTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -8,9 +8,11 @@
*/
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
-lmb_require('limb/macro/src/tags/include.tag.php');
lmb_require('limb/fs/src/lmbFs.class.php');
+lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/include.tag.php');
+
class lmbMacroTagIncludeTest extends UnitTestCase
{
function setUp()
Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php 2007-09-19 20:42:00 UTC (rev 6317)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php 2007-09-19 21:30:30 UTC (rev 6318)
@@ -9,10 +9,12 @@
lmb_require('limb/fs/src/lmbFs.class.php');
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
-lmb_require('limb/macro/src/tags/wrap.tag.php');
-lmb_require('limb/macro/src/tags/slot.tag.php');
-lmb_require('limb/macro/src/tags/into.tag.php');
+lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/wrap.tag.php');
+lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/slot.tag.php');
+lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/into.tag.php');
+
class lmbMacroWrapTagTest extends UnitTestCase
{
function setUp()
More information about the limb-svn
mailing list