function ValidKeysConstraintValidatorTest::setUp

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/TypedData/ValidKeysConstraintValidatorTest.php \Drupal\KernelTests\Core\TypedData\ValidKeysConstraintValidatorTest::setUp()

Overrides KernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/TypedData/ValidKeysConstraintValidatorTest.php, line 35

Class

ValidKeysConstraintValidatorTest
Tests the ValidKeys validation constraint.

Namespace

Drupal\KernelTests\Core\TypedData

Code

protected function setUp() : void {
  parent::setUp();
  // Install the Block module and create a Block config entity, so that we can
  // test that the validator infers the required keys from a defined schema.
  $this->enableModules([
    'system',
    'block',
  ]);
  // Also install the config_schema_test module, to enable testing with
  // config entities as the example in the test cases below, simulating both
  // possible schema states: fully validatable and not fully validatable.
  // @see \Drupal\KernelTests\Config\Schema\MappingTest::testMappingInterpretations()
  $this->enableModules([
    'config_schema_test',
  ]);
  /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
  $theme_installer = $this->container
    ->get('theme_installer');
  $theme_installer->install([
    'stark',
  ]);
  $block = Block::create([
    'id' => 'branding',
    'plugin' => 'system_branding_block',
    'theme' => 'stark',
    'status' => TRUE,
    'weight' => 0,
    'provider' => 'system',
    'settings' => [
      'use_site_logo' => TRUE,
      'use_site_name' => TRUE,
      'use_site_slogan' => TRUE,
      'label_display' => FALSE,
    ],
  ]);
  $block->save();
  $this->config = $this->container
    ->get('config.typed')
    ->get('block.block.branding');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.