mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
Partial implementation of unit test for template parser v2
This commit is contained in:
parent
a362f27f62
commit
9da1d56b21
4 changed files with 103 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
class TemplateParserV2Test extends \Codeception\TestCase\Test
|
||||
{
|
||||
private $prefix = '<?php if (!defined("RX_VERSION")) exit(); ?><?php $this->config->version = 2; ?>';
|
||||
private $baseurl;
|
||||
|
||||
public function _before()
|
||||
|
|
@ -9,8 +10,108 @@ class TemplateParserV2Test extends \Codeception\TestCase\Test
|
|||
$this->baseurl = '/' . basename(dirname(dirname(dirname(dirname(__DIR__))))) . '/';
|
||||
}
|
||||
|
||||
public function testParse()
|
||||
public function testVersion()
|
||||
{
|
||||
// Extension is .html and config is explicitly declared
|
||||
$source = '<config version="2" />' . "\n" . '<div>{{ RX_VERSION|noescape }}</div>';
|
||||
$target = '<div><?php echo RX_VERSION; ?></div>';
|
||||
$this->assertEquals($this->prefix . "\n" . $target, $this->_parse($source), false);
|
||||
|
||||
$source = '@version(2)' . "\n" . '<div>@php func_get_args(); @endphp</div>';
|
||||
$target = '<div><?php func_get_args(); ?></div>';
|
||||
$this->assertEquals($this->prefix . "\n" . $target, $this->_parse($source), false);
|
||||
|
||||
// Extension is .blade.php and config is not declared
|
||||
$source = '<input @disabled(foo())>';
|
||||
$target = '<input<?php if (foo()): ?> disabled="disabled"<?php endif; ?>>';
|
||||
$this->assertEquals($this->prefix . $target, $this->_parse($source));
|
||||
|
||||
// Extension is .blade.php but version is incorrectly declared: will be parsed as v1
|
||||
$source = '@version(1)' . "\n" . '<input @disabled(foo())>';
|
||||
$target = '<input @disabled(foo())>';
|
||||
$this->assertStringContainsString($target, $this->_parse($source));
|
||||
}
|
||||
|
||||
public function testClassAliases()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testInclude()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testAssetLoading()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testEchoStatements()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testOutputFilters()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testPathConversion()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testBlockConditions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testInlineConditions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testMiscDirectives()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testComments()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testVerbatim()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testRawPhpCode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testAutoEscape()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testCurlyBracesAndVars()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function testCompile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function _parse($source, $force_v2 = true)
|
||||
{
|
||||
$filename = $force_v2 ? 'v2example.blade.php' : 'no_file.html';
|
||||
$tmpl = new \Rhymix\Framework\Template('./tests/_data/template', $filename);
|
||||
$result = $tmpl->parse($source);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue