You are here

public function FieldBlockTest::testStatesFieldBlock in Drupal 9

Same name and namespace in other branches
  1. 8 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()

Tests configuring a field block that uses #states.

File

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

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/classy');
  $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');
}