class FakeTemplateWrapper
Same name in other branches
- 8.9.x core/modules/help_topics/tests/src/Unit/HelpTopicTwigTest.php \Drupal\Tests\help_topics\Unit\FakeTemplateWrapper
Defines a fake template class to mock \Twig\TemplateWrapper.
We cannot use getMockBuilder() for this, because the Twig TemplateWrapper class is declared "final" and cannot be mocked.
Hierarchy
- class \Drupal\Tests\help_topics\Unit\FakeTemplateWrapper
Expanded class hierarchy of FakeTemplateWrapper
File
-
core/
modules/ help_topics/ tests/ src/ Unit/ HelpTopicTwigTest.php, line 112
Namespace
Drupal\Tests\help_topics\UnitView source
class FakeTemplateWrapper {
/**
* Body text to return from the render() method.
*
* @var string
*/
protected $body;
/**
* Constructor.
*
* @param string $body
* Body text to return from the render() method.
*/
public function __construct($body) {
$this->body = $body;
}
/**
* Mocks the \Twig\TemplateWrapper render() method.
*
* @param array $context
* (optional) Render context.
*/
public function render(array $context = []) {
return $this->body;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
FakeTemplateWrapper::$body | protected | property | Body text to return from the render() method. |
FakeTemplateWrapper::render | public | function | Mocks the \Twig\TemplateWrapper render() method. |
FakeTemplateWrapper::__construct | public | function | Constructor. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.