You are here

protected function HelpTopicTwigLoaderTest::getHandlerMock in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/help_topics/tests/src/Unit/HelpTopicTwigLoaderTest.php \Drupal\Tests\help_topics\Unit\HelpTopicTwigLoaderTest::getHandlerMock()

Creates a mock module or theme handler class for the test.

Parameters

string $type: Type of handler to return: 'module' or 'theme'.

Return value

\PHPUnit\Framework\MockObject\MockObject The mock of module or theme handler.

1 call to HelpTopicTwigLoaderTest::getHandlerMock()
HelpTopicTwigLoaderTest::setUp in core/modules/help_topics/tests/src/Unit/HelpTopicTwigLoaderTest.php

File

core/modules/help_topics/tests/src/Unit/HelpTopicTwigLoaderTest.php, line 82

Class

HelpTopicTwigLoaderTest
Unit test for the HelpTopicTwigLoader class.

Namespace

Drupal\Tests\help_topics\Unit

Code

protected function getHandlerMock($type) {
  if ($type == 'module') {
    $class = 'Drupal\\Core\\Extension\\ModuleHandlerInterface';
    $method = 'getModuleDirectories';
  }
  else {
    $class = 'Drupal\\Core\\Extension\\ThemeHandlerInterface';
    $method = 'getThemeDirectories';
  }
  $handler = $this
    ->getMockBuilder($class)
    ->disableOriginalConstructor()
    ->getMock();
  $handler
    ->method($method)
    ->willReturn($this->directories[$type]);
  return $handler;
}