You are here

protected function WebformBlockTest::mockWebformBlock in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Unit/Plugin/Block/WebformBlockTest.php \Drupal\Tests\webform\Unit\Plugin\Block\WebformBlockTest::mockWebformBlock()

Create a mock webform block.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

Return value

\Drupal\webform\Plugin\Block\WebformBlock A mock webform block.

2 calls to WebformBlockTest::mockWebformBlock()
WebformBlockTest::testBlockAccess in tests/src/Unit/Plugin/Block/WebformBlockTest.php
Tests the access of a webform block.
WebformBlockTest::testCalculateDependencies in tests/src/Unit/Plugin/Block/WebformBlockTest.php
Tests the dependencies of a webform block.

File

tests/src/Unit/Plugin/Block/WebformBlockTest.php, line 113

Class

WebformBlockTest
Tests webform submission bulk form actions.

Namespace

Drupal\Tests\webform\Unit\Plugin\Block

Code

protected function mockWebformBlock(WebformInterface $webform) {
  $request_stack = $this
    ->getMockBuilder(RequestStack::class)
    ->disableOriginalConstructor()
    ->getMock();
  $entity_type_manager = $this
    ->getMockBuilder(EntityTypeManagerInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $storage = $this
    ->getMockBuilder(EntityStorageInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $storage
    ->method('load')
    ->willReturnMap([
    [
      $webform
        ->id(),
      $webform,
    ],
  ]);
  $entity_type_manager
    ->method('getStorage')
    ->willReturnMap([
    [
      'webform',
      $storage,
    ],
  ]);
  $token_manager = $this
    ->getMockBuilder(WebformTokenManagerInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $route_match = $this
    ->getMockBuilder(RouteMatchInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $configuration = [
    'webform_id' => $webform
      ->id(),
  ];
  $plugin_id = 'webform_block';
  $plugin_definition = [
    'provider' => 'unit_test',
  ];
  return new WebformBlock($configuration, $plugin_id, $plugin_definition, $request_stack, $entity_type_manager, $token_manager, $route_match);
}