-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f314671
commit 20625fb
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Template filters | ||
*/ | ||
|
||
use Nette\Bridges\ApplicationLatte\Template, | ||
Tester\Assert; | ||
|
||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
class LatteFactory implements Nette\Bridges\ApplicationLatte\ILatteFactory | ||
{ | ||
private $engine; | ||
|
||
public function __construct(Latte\Engine $engine) | ||
{ | ||
$this->engine = $engine; | ||
} | ||
|
||
public function create() | ||
{ | ||
return $this->engine; | ||
} | ||
} | ||
|
||
$engine = new \Latte\Engine(); | ||
$template = new Template($engine); | ||
|
||
Assert::exception(function () use ($template) { | ||
@$template->length('abc'); | ||
}, 'LogicException', "Filter 'length' is not defined."); | ||
|
||
$engine->addFilter('length', 'strlen'); | ||
|
||
Assert::same( 3, @$template->length('abc') ); | ||
|
||
Assert::error(function () use ($template) { | ||
$template->length('abc'); | ||
}, E_USER_DEPRECATED, 'Invoking filters on Template object outside of template file is deprecated, use your filter directly.'); |