Skip to content

Commit

Permalink
Slice filter test case (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
lulco authored Aug 24, 2023
1 parent 63beb23 commit caf661c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ public function testFilters(): void
{
$this->analyse([__DIR__ . '/Fixtures/FiltersPresenter.php', __DIR__ . '/Fixtures/ParentPresenter.php'], [
'NODE NetteApplicationUIPresenter {"className":"FiltersPresenter"}',
'TEMPLATE default.latte FiltersPresenter::default ["startupParent","presenter","control","flashes","title","someObject"] ["parentForm","header","footer"]',
'TEMPLATE default.latte FiltersPresenter::default ["startupParent","presenter","control","flashes","title","subtitle","someObject"] ["parentForm","header","footer"]',
'TEMPLATE parent.latte FiltersPresenter::parent ["startupParent","presenter","control","flashes","variableFromParentAction"] ["parentForm","header","footer","parentDefaultForm"]',
'TEMPLATE translate_new.latte FiltersPresenter:: ["startupParent","presenter","control","flashes"] ["parentForm","header","footer"]',
'TEMPLATE @layout.latte FiltersPresenter::default ["startupParent","presenter","control","flashes","title","someObject"] ["parentForm","header","footer"]',
'TEMPLATE @layout.latte FiltersPresenter::default ["startupParent","presenter","control","flashes","title","subtitle","someObject"] ["parentForm","header","footer"]',
'TEMPLATE @layout.latte FiltersPresenter::parent ["startupParent","presenter","control","flashes","variableFromParentAction"] ["parentForm","header","footer","parentDefaultForm"]',
'TEMPLATE @layout.latte FiltersPresenter:: ["startupParent","presenter","control","flashes"] ["parentForm","header","footer"]',
'NODE NetteApplicationUIPresenter {"className":"ParentPresenter"}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

final class FiltersPresenter extends ParentPresenter
{
private ?string $subtitle = null;

protected function startup()
{
parent::startup();
Expand All @@ -22,6 +24,7 @@ public function actionDefault(): void
return uniqid($string);
});
$this->template->title = 'foo';
$this->template->subtitle = $this->subtitle;
$this->template->someObject = new stdClass();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
{$someObject|lower}
{$someObject|upper}
{$someObject|capitalize}
{$subtitle|slice: 0, 2}
{/block}
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,17 @@ public function testFilters(): void
21,
'default.latte',
];
$expectedErrors[] = [
'Parameter #1 $value of static method Latte\Essential\Filters::slice() expects array|string, string|null given.',
22,
'default.latte',
];
$expectedErrors[] = [
'Unable to resolve the template type T in call to method static method Latte\Essential\Filters::slice()',
22,
'default.latte',
'See: https://phpstan.org/blog/solving-phpstan-error-unable-to-resolve-template-type',
];
} else {
$expectedErrors[] = [
'Syntax error, unexpected \')\'',
Expand Down Expand Up @@ -953,6 +964,17 @@ public function testFilters(): void
21,
'default.latte',
];
$expectedErrors[] = [
'Parameter #1 $value of static method Latte\Runtime\Filters::slice() expects array|string, string|null given.',
22,
'default.latte',
];
$expectedErrors[] = [
'Unable to resolve the template type T in call to method static method Latte\Runtime\Filters::slice()',
22,
'default.latte',
'See: https://phpstan.org/blog/solving-phpstan-error-unable-to-resolve-template-type',
];
}

$this->analyse([__DIR__ . '/Fixtures/FiltersPresenter.php'], $expectedErrors);
Expand Down

0 comments on commit caf661c

Please sign in to comment.