You are here

protected function WebformBrowserTestTrait::placeWebformBlocks in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/WebformBrowserTestTrait.php \Drupal\Tests\webform\Traits\WebformBrowserTestTrait::placeWebformBlocks()

Place webform test module blocks.

Parameters

string $module_name: Test module name.

2 calls to WebformBrowserTestTrait::placeWebformBlocks()
WebformNodeTest::setUp in modules/webform_node/tests/src/Functional/WebformNodeTest.php
WebformSettingsLimitsTest::setUp in tests/src/Functional/Settings/WebformSettingsLimitsTest.php

File

tests/src/Traits/WebformBrowserTestTrait.php, line 41

Class

WebformBrowserTestTrait
Provides convenience methods for webform assertions in browser tests.

Namespace

Drupal\Tests\webform\Traits

Code

protected function placeWebformBlocks($module_name) {
  $config_directory = drupal_get_path('module', 'webform') . '/tests/modules/' . $module_name . '/config';
  $config_files = \Drupal::service('file_system')
    ->scanDirectory($config_directory, '/block\\..*/');
  foreach ($config_files as $config_file) {
    $data = Yaml::decode(file_get_contents($config_file->uri));
    $plugin_id = $data['plugin'];
    $settings = $data['settings'];
    unset($settings['id']);
    $this
      ->drupalPlaceBlock($plugin_id, $settings);
  }
}