function FieldBlockTest::testStatesFieldBlock

Same name in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::testStatesFieldBlock()
  2. 10 core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::testStatesFieldBlock()
  3. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\FieldBlockTest::testStatesFieldBlock()

Tests configuring a field block that uses #states.

File

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

Class

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

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

public function testStatesFieldBlock() {
    $page = $this->getSession()
        ->getPage();
    $timestamp_field_storage = FieldStorageConfig::create([
        'field_name' => 'field_timestamp',
        'entity_type' => 'user',
        'type' => 'timestamp',
    ]);
    $timestamp_field_storage->save();
    $timestamp_field = FieldConfig::create([
        'field_storage' => $timestamp_field_storage,
        'bundle' => 'user',
        'label' => 'Timestamp',
    ]);
    $timestamp_field->save();
    $this->drupalGet('admin/structure/block/add/field_block_test%3Auser%3Auser%3Afield_timestamp/starterkit_theme');
    $this->assertFalse($page->findField('settings[formatter][settings][custom_date_format]')
        ->isVisible(), 'Custom date format is not visible');
    $page->selectFieldOption('settings[formatter][settings][date_format]', 'custom');
    $this->assertTrue($page->findField('settings[formatter][settings][custom_date_format]')
        ->isVisible(), 'Custom date format is visible');
}

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