function FieldBlockTest::setUp

Same name in this branch
  1. 10 core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::setUp()
Same name in other branches
  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()
  3. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::setUp()
  4. 8.9.x core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::setUp()
  5. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::setUp()
  6. 11.x core/modules/layout_builder/tests/src/Kernel/FieldBlockTest.php \Drupal\Tests\layout_builder\Kernel\FieldBlockTest::setUp()

Overrides BrowserTestBase::setUp

File

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

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

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