function 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 104

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->getMockBuilder(Template::class)
    ->onlyMethods([
    'render',
    'getTemplateName',
    'getDebugInfo',
    'getSourceContext',
    'doDisplay',
  ])
    ->setConstructorArgs([
    $twig,
  ])
    ->getMock();
  $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.