You are here

public function ViewsBulkEditTest::testFieldsNotDisplayedAreIgnored in Views Bulk Edit 8

Test non-configured fields are not displayed.

File

tests/src/Functional/ViewsBulkEditTest.php, line 136

Class

ViewsBulkEditTest
Tests the Views Bulk Edit feature.

Namespace

Drupal\Tests\views_bulk_edit\Functional

Code

public function testFieldsNotDisplayedAreIgnored() {
  EntityFormMode::create([
    'id' => 'node.bulk_edit',
    'label' => 'Bulk Edit',
    'targetEntityType' => 'node',
  ])
    ->save();
  $display = EntityFormDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => 'page',
    'mode' => 'bulk_edit',
    'status' => TRUE,
  ]);
  $page1 = $this
    ->createNode();
  $this
    ->drupalPostForm('/admin/content', [
    'action' => 'node_bulk_edit',
    'node_bulk_form[0]' => $this
      ->getBulkKey($page1),
  ], 'Apply to selected items');
  $this
    ->assertSession()
    ->fieldExists('page[field_selector][title]');

  // Update the display to hide the title.
  $display
    ->removeComponent('title')
    ->save();

  // Node the title field should no longer be displayed.
  $this
    ->drupalPostForm('/admin/content', [
    'action' => 'node_bulk_edit',
    'node_bulk_form[0]' => $this
      ->getBulkKey($page1),
  ], 'Apply to selected items');
  $this
    ->assertSession()
    ->fieldNotExists('page[field_selector][title]');
}