You are here

public function WebformBlockTest::testCalculateDependencies 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::testCalculateDependencies()

Tests the dependencies of a webform block.

File

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

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.');
}