You are here

protected function FieldBlockTest::setUp in Drupal 9

Same name in this branch
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::setUp()
  2. 9 core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::setUp()
Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php, line 36

Class

FieldBlockTest
@coversDefaultClass \Drupal\layout_builder\Plugin\Block\FieldBlock

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'field_date',
    'entity_type' => 'user',
    'type' => 'datetime',
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'user',
    'label' => 'Date field',
  ]);
  $field
    ->save();
  $user = $this
    ->drupalCreateUser([
    'administer blocks',
    'access administration pages',
  ]);
  $user->field_date = '1978-11-19T05:00:00';
  $user
    ->save();
  $this
    ->drupalLogin($user);
}