function HelpTopicTwigTest::getTwigMock

Same name and namespace in other branches
  1. 9 core/modules/help_topics/tests/src/Unit/HelpTopicTwigTest.php \Drupal\Tests\help_topics\Unit\HelpTopicTwigTest::getTwigMock()
  2. 8.9.x core/modules/help_topics/tests/src/Unit/HelpTopicTwigTest.php \Drupal\Tests\help_topics\Unit\HelpTopicTwigTest::getTwigMock()
  3. 11.x core/modules/help/tests/src/Unit/HelpTopicTwigTest.php \Drupal\Tests\help\Unit\HelpTopicTwigTest::getTwigMock()

Creates a mock Twig loader class for the test.

1 call to HelpTopicTwigTest::getTwigMock()
HelpTopicTwigTest::setUp in core/modules/help/tests/src/Unit/HelpTopicTwigTest.php

File

core/modules/help/tests/src/Unit/HelpTopicTwigTest.php, line 97

Class

HelpTopicTwigTest
Unit test for the HelpTopicTwig class.

Namespace

Drupal\Tests\help\Unit

Code

protected function getTwigMock() {
    $twig = $this->getMockBuilder('Drupal\\Core\\Template\\TwigEnvironment')
        ->disableOriginalConstructor()
        ->getMock();
    $template = $this->getMockForAbstractClass(Template::class, [
        $twig,
    ], '', TRUE, TRUE, TRUE, [
        'render',
    ]);
    $template->method('render')
        ->willReturn(self::PLUGIN_INFORMATION['body']);
    $twig->method('load')
        ->willReturn(new TemplateWrapper($twig, $template));
    return $twig;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.