mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Merge pull request #270 from fenom-template/develop
Fix bugs; phpunit things
This commit is contained in:
commit
7d0db43050
@ -11,10 +11,11 @@ php:
|
|||||||
- 7.1
|
- 7.1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer update --dev --quiet
|
- composer global require satooshi/php-coveralls
|
||||||
|
# - composer update --dev --quiet
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpunit
|
- phpunit -c phpunit.xml.dist
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- php vendor/bin/coveralls
|
- coveralls
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"ext-tokenizer": "*"
|
"ext-tokenizer": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "*",
|
"phpunit/phpunit": "<6.0",
|
||||||
"satooshi/php-coveralls": "*"
|
"satooshi/php-coveralls": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
908
composer.lock
generated
908
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
|||||||
Модификатор in
|
Модификатор in
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Модификатор является реализацией оператора содержания [in](../operators.md#Оператор-содержания).
|
Модификатор является реализацией оператора содержания [in](../operators.md#Оператор-содержания).
|
||||||
|
|
||||||
```smarty
|
```smarty
|
||||||
|
@ -6,11 +6,13 @@ require_once __DIR__.'/../tests/tools.php';
|
|||||||
\Fenom::registerAutoload();
|
\Fenom::registerAutoload();
|
||||||
|
|
||||||
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled');
|
$fenom = Fenom::factory(__DIR__.'/templates', __DIR__.'/compiled');
|
||||||
$fenom->setOptions(Fenom::AUTO_RELOAD | Fenom::FORCE_VERIFY | Fenom::FORCE_INCLUDE);
|
//$fenom->setOptions(Fenom::AUTO_RELOAD | Fenom::FORCE_VERIFY | Fenom::FORCE_INCLUDE);
|
||||||
//var_dump($fenom->compile("nested.tpl", [])->getTemplateCode());
|
//var_dump($fenom->compile("nested.tpl", [])->getTemplateCode());
|
||||||
//exit;
|
//exit;
|
||||||
var_dump($fenom->compile('bug241/recursive.tpl', false)->getBody());
|
//var_dump($fenom->compile('bug241/recursive.tpl', false)->getBody());
|
||||||
//var_dump($fenom->compile('bug249/bread.tpl', false)->getBody());
|
//var_dump($fenom->compile('bug249/bread.tpl', false)->getBody());
|
||||||
//var_dump($fenom->compile("bug158/main.tpl", [])->getTemplateCode());
|
//var_dump($fenom->compile("bug158/main.tpl", [])->getTemplateCode());
|
||||||
//var_dump($fenom->display("bug158/main.tpl", []));
|
//var_dump($fenom->display("bug158/main.tpl", []));
|
||||||
// $fenom->getTemplate("problem.tpl");
|
// $fenom->getTemplate("problem.tpl");
|
||||||
|
|
||||||
|
var_dump($fenom->compileCode('{$.php.Fenom::factory()->addDay()}')->getBody());
|
||||||
|
@ -829,7 +829,14 @@ class Template extends Render
|
|||||||
case '$':
|
case '$':
|
||||||
$code = $this->parseAccessor($tokens, $is_var);
|
$code = $this->parseAccessor($tokens, $is_var);
|
||||||
if (!$is_var) {
|
if (!$is_var) {
|
||||||
|
if($tokens->is(T_OBJECT_OPERATOR)) {
|
||||||
|
if ($this->_options & Fenom::DENY_METHODS) {
|
||||||
|
throw new \LogicException("Forbidden to call methods");
|
||||||
|
}
|
||||||
|
$code = $unary . $this->parseChain($tokens, $code);
|
||||||
|
} else {
|
||||||
$code = $unary . $code;
|
$code = $unary . $code;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* no break */
|
/* no break */
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
require(__DIR__ . "/../src/Fenom.php");
|
require(__DIR__ . "/../src/Fenom.php");
|
||||||
Fenom::registerAutoload();
|
Fenom::registerAutoload();
|
||||||
|
|
||||||
|
if(!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
|
||||||
|
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
|
||||||
|
}
|
||||||
|
|
||||||
define('FENOM_RESOURCES', __DIR__ . "/resources");
|
define('FENOM_RESOURCES', __DIR__ . "/resources");
|
||||||
|
|
||||||
require_once FENOM_RESOURCES . "/actions.php";
|
require_once FENOM_RESOURCES . "/actions.php";
|
||||||
@ -10,3 +14,4 @@ require_once __DIR__ . "/TestCase.php";
|
|||||||
require_once __DIR__ . "/tools.php";
|
require_once __DIR__ . "/tools.php";
|
||||||
|
|
||||||
ini_set('date.timezone', 'Europe/Moscow');
|
ini_set('date.timezone', 'Europe/Moscow');
|
||||||
|
|
||||||
|
@ -94,58 +94,66 @@ class AccessorTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function providerPHP() {
|
public static function providerCall() {
|
||||||
return array(
|
return array(
|
||||||
array('$.php.strrev("string")', strrev("string")),
|
array('$.call.strrev("string")', strrev("string")),
|
||||||
array('$.php.strrev("string")', strrev("string"), 'str*'),
|
array('$.call.strrev("string")', strrev("string"), 'str*'),
|
||||||
array('$.php.strrev("string")', strrev("string"), 'strrev'),
|
array('$.call.strrev("string")', strrev("string"), 'strrev'),
|
||||||
array('$.php.get_current_user', get_current_user()),
|
array('$.call.get_current_user', get_current_user()),
|
||||||
array('$.php.Fenom.helper_func("string", 12)', helper_func("string", 12)),
|
array('$.call.Fenom.helper_func("string", 12)', helper_func("string", 12)),
|
||||||
array('$.php.Fenom.helper_func("string", 12)', helper_func("string", 12), 'Fenom\\*'),
|
array('$.call.Fenom.helper_func("string", 12)', helper_func("string", 12), 'Fenom\\*'),
|
||||||
array('$.php.Fenom.helper_func("string", 12)', helper_func("string", 12), 'Fenom\helper_func'),
|
array('$.call.Fenom.helper_func("string", 12)', helper_func("string", 12), 'Fenom\helper_func'),
|
||||||
array('$.php.Fenom.helper_func("string", 12)', helper_func("string", 12), '*helper_func'),
|
array('$.call.Fenom.helper_func("string", 12)', helper_func("string", 12), '*helper_func'),
|
||||||
array('$.php.Fenom.helper_func("string", 12)', helper_func("string", 12), '*'),
|
array('$.call.Fenom.helper_func("string", 12)', helper_func("string", 12), '*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string")),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string")),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\*'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\TestCase*'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\TestCase*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\TestCase::*'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\TestCase::*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\*::dots'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\*::dots'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\*::*'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\*::*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\TestCase::dots'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), 'Fenom\TestCase::dots'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), '*::dots'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), '*::dots'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', TestCase::dots("string"), '*'),
|
array('$.call.Fenom.TestCase::dots("string")', TestCase::dots("string"), '*'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerPHP
|
* @dataProvider providerCall
|
||||||
* @group php
|
* @group php
|
||||||
*/
|
*/
|
||||||
public function testPHP($tpl, $result, $mask = null) {
|
public function testCall($tpl, $result, $mask = null) {
|
||||||
if($mask) {
|
if($mask) {
|
||||||
$this->fenom->addCallFilter($mask);
|
$this->fenom->addCallFilter($mask);
|
||||||
}
|
}
|
||||||
$this->assertRender('{'.$tpl.'}', $result);
|
$this->assertRender('{'.$tpl.'}', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group issue260
|
||||||
|
*/
|
||||||
|
public function testBug260() {
|
||||||
|
$this->fenom->compileCode('{$.php.Fenom::factory()->addModifier("intval", "intval")}');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function providerPHPInvalid() {
|
public static function providerPHPInvalid() {
|
||||||
return array(
|
return array(
|
||||||
array('$.php.aaa("string")', 'Fenom\Error\CompileException', 'PHP method aaa does not exists'),
|
array('$.call.aaa("string")', 'Fenom\Error\CompileException', 'PHP method aaa does not exists'),
|
||||||
array('$.php.strrev("string")', 'Fenom\Error\SecurityException', 'Callback strrev is not available by settings', 'strrevZ'),
|
array('$.call.strrev("string")', 'Fenom\Error\SecurityException', 'Callback strrev is not available by settings', 'strrevZ'),
|
||||||
array('$.php.strrev("string")', 'Fenom\Error\SecurityException', 'Callback strrev is not available by settings', 'str*Z'),
|
array('$.call.strrev("string")', 'Fenom\Error\SecurityException', 'Callback strrev is not available by settings', 'str*Z'),
|
||||||
array('$.php.strrev("string")', 'Fenom\Error\SecurityException', 'Callback strrev is not available by settings', '*Z'),
|
array('$.call.strrev("string")', 'Fenom\Error\SecurityException', 'Callback strrev is not available by settings', '*Z'),
|
||||||
array('$.php.Fenom.aaa("string")', 'Fenom\Error\CompileException', 'PHP method Fenom.aaa does not exists'),
|
array('$.call.Fenom.aaa("string")', 'Fenom\Error\CompileException', 'PHP method Fenom.aaa does not exists'),
|
||||||
array('$.php.Fenom.helper_func("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.helper_func is not available by settings', 'Reflection\*'),
|
array('$.call.Fenom.helper_func("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.helper_func is not available by settings', 'Reflection\*'),
|
||||||
array('$.php.Fenom.helper_func("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.helper_func is not available by settings', 'Fenom\*Z'),
|
array('$.call.Fenom.helper_func("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.helper_func is not available by settings', 'Fenom\*Z'),
|
||||||
array('$.php.Fenom.helper_func("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.helper_func is not available by settings', 'Fenom\*::*'),
|
array('$.call.Fenom.helper_func("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.helper_func is not available by settings', 'Fenom\*::*'),
|
||||||
array('$.php.TestCase::aaa("string")', 'Fenom\Error\CompileException', 'PHP method TestCase::aaa does not exists'),
|
array('$.call.TestCase::aaa("string")', 'Fenom\Error\CompileException', 'PHP method TestCase::aaa does not exists'),
|
||||||
array('$.php.Fenom.TestCase::aaa("string")', 'Fenom\Error\CompileException', 'PHP method Fenom.TestCase::aaa does not exists'),
|
array('$.call.Fenom.TestCase::aaa("string")', 'Fenom\Error\CompileException', 'PHP method Fenom.TestCase::aaa does not exists'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Reflection\*'),
|
array('$.call.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Reflection\*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\*Z'),
|
array('$.call.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\*Z'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\*::get*'),
|
array('$.call.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\*::get*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\TestCase::get*'),
|
array('$.call.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\TestCase::get*'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\TestCase::*Z'),
|
array('$.call.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', 'Fenom\TestCase::*Z'),
|
||||||
array('$.php.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', '*::*Z'),
|
array('$.call.Fenom.TestCase::dots("string")', 'Fenom\Error\SecurityException', 'Callback Fenom.TestCase::dots is not available by settings', '*::*Z'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +266,7 @@ class AccessorTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group dev
|
*
|
||||||
*/
|
*/
|
||||||
public function testCallbackAccessor() {
|
public function testCallbackAccessor() {
|
||||||
$index = 1;
|
$index = 1;
|
||||||
|
@ -4,7 +4,7 @@ namespace Fenom;
|
|||||||
use Fenom,
|
use Fenom,
|
||||||
Fenom\Render;
|
Fenom\Render;
|
||||||
|
|
||||||
class RenderTest extends \PHPUnit_Framework_TestCase
|
class RenderTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@ namespace Fenom;
|
|||||||
use Fenom\Error\UnexpectedTokenException;
|
use Fenom\Error\UnexpectedTokenException;
|
||||||
use Fenom\Tokenizer;
|
use Fenom\Tokenizer;
|
||||||
|
|
||||||
class TokenizerTest extends \PHPUnit_Framework_TestCase
|
class TokenizerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
public function testGetName()
|
public function testGetName()
|
||||||
|
Loading…
Reference in New Issue
Block a user