mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Big update
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Aspect;
|
||||
use Aspect;
|
||||
use Aspect, Aspect\FSProvider as FS;
|
||||
|
||||
class TestCase extends \PHPUnit_Framework_TestCase {
|
||||
/**
|
||||
@ -12,7 +12,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
|
||||
if(!file_exists(ASPECT_RESOURCES.'/compile')) {
|
||||
mkdir(ASPECT_RESOURCES.'/compile', 0777, true);
|
||||
} else {
|
||||
Misc::clean(ASPECT_RESOURCES.'/compile/');
|
||||
FS::clean(ASPECT_RESOURCES.'/compile/');
|
||||
}
|
||||
$this->aspect = Aspect::factory(ASPECT_RESOURCES.'/template', ASPECT_RESOURCES.'/compile');
|
||||
}
|
||||
@ -21,7 +21,7 @@ class TestCase extends \PHPUnit_Framework_TestCase {
|
||||
if(!file_exists(ASPECT_RESOURCES.'/template')) {
|
||||
mkdir(ASPECT_RESOURCES.'/template', 0777, true);
|
||||
} else {
|
||||
Misc::clean(ASPECT_RESOURCES.'/template/');
|
||||
FS::clean(ASPECT_RESOURCES.'/template/');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class ExtendsTemplateTest extends TestCase {
|
||||
* @param $vars
|
||||
* @param $result
|
||||
*/
|
||||
public function testDynamicExtends($name, $code, $vars, $result) {
|
||||
public function _testDynamicExtends($name, $code, $vars, $result) {
|
||||
static $i = 0;
|
||||
$vars["iteration"] = $i++;
|
||||
$this->execTpl($name, $code, $vars, $result);
|
||||
@ -60,7 +60,7 @@ class ExtendsTemplateTest extends TestCase {
|
||||
/**
|
||||
* @group extends
|
||||
*/
|
||||
public function _testChildLevel1() {
|
||||
public function testChildLevel1() {
|
||||
//echo($this->aspect->fetch("child1.tpl", array("a" => "a char"))); exit;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace Aspect\Provider;
|
||||
namespace Aspect;
|
||||
use Aspect;
|
||||
|
||||
class FSTest extends \Aspect\TestCase {
|
||||
class FSProviderTest extends \Aspect\TestCase {
|
||||
/**
|
||||
* @var Provider
|
||||
* @var FSProvider
|
||||
*/
|
||||
public $provider;
|
||||
|
||||
@ -12,7 +12,7 @@ class FSTest extends \Aspect\TestCase {
|
||||
parent::setUp();
|
||||
$this->tpl("template1.tpl", 'Template 1 {$a}');
|
||||
$this->tpl("template2.tpl", 'Template 2 {$a}');
|
||||
$this->provider = new FS(ASPECT_RESOURCES.'/template');
|
||||
$this->provider = new FSProvider(ASPECT_RESOURCES.'/template');
|
||||
}
|
||||
|
||||
public function testIsTemplateExists() {
|
@ -15,6 +15,10 @@ class TemplateTest extends TestCase {
|
||||
)));
|
||||
}
|
||||
|
||||
/*public function testSandbox() {
|
||||
var_dump($this->aspect->compileCode('{"$s:{$b+1}f d {$d}"}')->_body);
|
||||
exit;
|
||||
}*/
|
||||
|
||||
public static function providerVars() {
|
||||
$a = array("a" => "World");
|
||||
@ -69,6 +73,42 @@ class TemplateTest extends TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public static function providerScalars() {
|
||||
return array(
|
||||
array('77', 77),
|
||||
array('-33', -33),
|
||||
array('0.2', 0.2),
|
||||
array('-0.3', -0.3),
|
||||
array('1e6', 1e6),
|
||||
array('-2e6', -2e6),
|
||||
array('"str"', 'str'),
|
||||
array('"str\nand\nmany\nlines"', "str\nand\nmany\nlines"),
|
||||
array('"str and \'substr\'"', "str and 'substr'"),
|
||||
array('"str and \"substr\""', 'str and "substr"'),
|
||||
array("'str'", 'str'),
|
||||
array("'str\\nin\\none\\nline'", 'str\nin\none\nline'),
|
||||
array("'str and \"substr\"'", 'str and "substr"'),
|
||||
array("'str and \'substr\''", "str and 'substr'"),
|
||||
array('"$one"', '1'),
|
||||
array('"$one $two"', '1 2'),
|
||||
array('"$one and $two"', '1 and 2'),
|
||||
array('"a $one and $two b"', 'a 1 and 2 b'),
|
||||
array('"{$one}"', '1'),
|
||||
array('"a {$one} b"', 'a 1 b'),
|
||||
array('"{$one + 2}"', '3'),
|
||||
array('"{$one * $two + 1}"', '3'),
|
||||
array('"{$one} and {$two}"', '1 and 2'),
|
||||
array('"$one and {$two}"', '1 and 2'),
|
||||
array('"{$one} and $two"', '1 and 2'),
|
||||
array('"a {$one} and {$two} b"', 'a 1 and 2 b'),
|
||||
array('"{$one+1} and {$two-1}"', '2 and 1'),
|
||||
array('"a {$one+1} and {$two-1} b"', 'a 2 and 1 b'),
|
||||
array('"a {$one|dots} and {$two|dots} b"', 'a 1... and 2... b'),
|
||||
array('"a {$one|dots} and $two b"', 'a 1... and 2 b'),
|
||||
array('"a $one and {$two|dots} b"', 'a 1 and 2... b'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function providerVarsInvalid() {
|
||||
return array(
|
||||
array('hello, {$a.}!', 'Aspect\CompileException', "Unexpected end of expression"),
|
||||
|
Reference in New Issue
Block a user