mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Add tests for partial import
This commit is contained in:
@@ -14,6 +14,10 @@ class MacrosTest extends TestCase {
|
||||
x - y - z = {$x - $y - $z}
|
||||
{/macro}
|
||||
|
||||
{macro multi(x, y)}
|
||||
x * y = {$x * $y}
|
||||
{/macro}
|
||||
|
||||
Math: {macro.plus x=2 y=3}, {macro.minus x=10 y=4}
|
||||
');
|
||||
|
||||
@@ -23,6 +27,21 @@ class MacrosTest extends TestCase {
|
||||
|
||||
Imp: {macro.plus x=1 y=2}, {math.minus x=6 y=2 z=1}
|
||||
');
|
||||
|
||||
$this->tpl("import_custom.tpl", '
|
||||
{macro minus(x, y)}
|
||||
new minus macros
|
||||
{/macro}
|
||||
{import [plus, minus] from "math.tpl" as math}
|
||||
|
||||
a: {math.plus x=1 y=2}, {math.minus x=6 y=2 z=1}, {macro.minus x=5 y=3}.
|
||||
');
|
||||
|
||||
$this->tpl("import_miss.tpl", '
|
||||
{import [minus] from "math.tpl" as math}
|
||||
|
||||
a: {macro.plus x=5 y=3}.
|
||||
');
|
||||
}
|
||||
|
||||
public function testMacros() {
|
||||
@@ -37,4 +56,20 @@ class MacrosTest extends TestCase {
|
||||
|
||||
$this->assertSame('Imp: x + y = 3 , x - y - z = 3', Modifier::strip($tpl->fetch(array()), true));
|
||||
}
|
||||
|
||||
public function testImportCustom() {
|
||||
$tpl = $this->aspect->compile('import_custom.tpl');
|
||||
|
||||
$this->assertSame('a: x + y = 3 , x - y - z = 3 , new minus macros .', Modifier::strip($tpl->fetch(array()), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedExceptionMessage Undefined macro 'plus'
|
||||
* @expectedException \Aspect\CompileException
|
||||
*/
|
||||
public function testImportMiss() {
|
||||
$tpl = $this->aspect->compile('import_miss.tpl');
|
||||
|
||||
$this->assertSame('a: x + y = 3 , x - y - z = 3 , new minus macros .', Modifier::strip($tpl->fetch(array()), true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user