You are here

protected function MetadataAssertionTest::setUp in Rules 8.3

Overrides RulesKernelTestBase::setUp

File

tests/src/Kernel/Engine/MetadataAssertionTest.php, line 34

Class

MetadataAssertionTest
Tests asserting metadata works correctly.

Namespace

Drupal\Tests\rules\Kernel\Engine

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installEntitySchema('user');

  // The global CurrentUserContext doesn't work properly without a
  // fully-installed user module.
  // @see https://www.drupal.org/project/rules/issues/2989417
  $this->container
    ->get('module_handler')
    ->loadInclude('user', 'install');
  user_install();
  $this
    ->installEntitySchema('node');
  $this
    ->installConfig([
    'field',
  ]);
  $entity_type_manager = $this->container
    ->get('entity_type.manager');
  $entity_type_manager
    ->getStorage('node_type')
    ->create([
    'type' => 'page',
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_text',
    'type' => 'string',
    'entity_type' => 'node',
    'cardinality' => 1,
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_text',
    'entity_type' => 'node',
    'bundle' => 'page',
  ])
    ->save();
}