You are here

public function WebformBlockTest::testCalculateDependencies in Webform 6.x

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

Tests the dependencies of a webform block.

File

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

Class

WebformBlockTest
Tests webform submission bulk form actions.

Namespace

Drupal\Tests\webform\Unit\Plugin\Block

Code

public function testCalculateDependencies() {

  // Create mock webform and webform block.
  $webform = $this
    ->getMockBuilder(WebformInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $webform
    ->method('id')
    ->willReturn($this
    ->randomMachineName());
  $webform
    ->method('getConfigDependencyKey')
    ->willReturn('config');
  $webform
    ->method('getConfigDependencyName')
    ->willReturn('config.webform.' . $webform
    ->id());
  $block = $this
    ->mockWebformBlock($webform);
  $dependencies = $block
    ->calculateDependencies();
  $expected = [
    $webform
      ->getConfigDependencyKey() => [
      $webform
        ->getConfigDependencyName(),
    ],
  ];
  $this
    ->assertEquals($expected, $dependencies, 'WebformBlock reports proper dependencies.');
}