Story
As an integrator, I want a view helper that eases my templates or adds some cool new functionality, because the developer wants to add their test for it ;)
As a developer, I want to have an example for a good view helper test so that I can copy from it for my own extension when I create custom view helpers there.
Acceptance criteria
Additional information
This is the code for the functional test I came up with in my own project, maybe it helps. Putting it here so it doesn‘t get lost:
$template = '{namespace tea=TTN\\Tea\\ViewHelpers}<tea:my.viewHelper attribute="{attribute}">{content}</tea:my.viewHelper>';
/** @var FluidViewAdapter $view */
$view = GeneralUtility::makeInstance(ViewFactoryInterface::class)
->create(new ViewFactoryData());
$view->getRenderingContext()->getTemplatePaths()->setTemplateSource($template);
$view->assignMultiple([
'attribute' => $attribute,
'content' => $content,
]);
$result = $view->render();
$this->assertSame('Expected result', $result);
More code examples (still V11-compatible, so might need some adaption):
Story
As an integrator, I want a view helper that eases my templates or adds some cool new functionality, because the developer wants to add their test for it ;)
As a developer, I want to have an example for a good view helper test so that I can copy from it for my own extension when I create custom view helpers there.
Acceptance criteria
#[DataProvider]attribute to show how to test the VH for various input variantsAdditional information
This is the code for the functional test I came up with in my own project, maybe it helps. Putting it here so it doesn‘t get lost:
More code examples (still V11-compatible, so might need some adaption):