function FieldBlockTest::testStatesFieldBlock
Tests configuring a field block that uses #states.
File
- 
              core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ FieldBlockTest.php, line 146  
Class
- FieldBlockTest
 - @coversDefaultClass \Drupal\layout_builder\Plugin\Block\FieldBlock[[api-linebreak]]
 
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testStatesFieldBlock() : void {
  $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.