You are here

public function LayoutSectionTest::testLayoutDeletingField in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::testLayoutDeletingField()
  2. 9 core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php \Drupal\Tests\layout_builder\Functional\LayoutSectionTest::testLayoutDeletingField()

Tests that deleting a field removes it from the layout.

File

core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php, line 245

Class

LayoutSectionTest
Tests the rendering of a layout section field.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testLayoutDeletingField() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet('/admin/structure/types/manage/bundle_with_section_field/display/default/layout');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->elementExists('css', '.field--name-body');

  // Delete the field from both bundles.
  $this
    ->drupalGet('/admin/structure/types/manage/bundle_without_section_field/fields/node.bundle_without_section_field.body/delete');
  $this
    ->submitForm([], 'Delete');
  $this
    ->drupalGet('/admin/structure/types/manage/bundle_with_section_field/display/default/layout');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->elementExists('css', '.field--name-body');
  $this
    ->drupalGet('/admin/structure/types/manage/bundle_with_section_field/fields/node.bundle_with_section_field.body/delete');
  $this
    ->submitForm([], 'Delete');
  $this
    ->drupalGet('/admin/structure/types/manage/bundle_with_section_field/display/default/layout');
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->elementNotExists('css', '.field--name-body');
}