You are here

public function ViewsBulkOperationsBulkFormTest::testActionCorePreconfig in Views Bulk Operations (VBO) 8.3

Same name and namespace in other branches
  1. 4.0.x tests/src/Functional/ViewsBulkOperationsBulkFormTest.php \Drupal\Tests\views_bulk_operations\Functional\ViewsBulkOperationsBulkFormTest::testActionCorePreconfig()

Test core action - specific configuration.

File

tests/src/Functional/ViewsBulkOperationsBulkFormTest.php, line 268

Class

ViewsBulkOperationsBulkFormTest
@coversDefaultClass \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm @group views_bulk_operations

Namespace

Drupal\Tests\views_bulk_operations\Functional

Code

public function testActionCorePreconfig() {
  $assertSession = $this
    ->assertSession();
  $testViewConfig = \Drupal::service('config.factory')
    ->getEditable('views.view.views_bulk_operations_test');
  $configData = $testViewConfig
    ->getRawData();
  $preconfig =& $configData['display']['default']['display_options']['fields']['views_bulk_operations_bulk_form']['selected_actions'][0]['preconfiguration'];
  $preconfig['add_confirmation'] = TRUE;
  $testViewConfig
    ->setData($configData);
  $testViewConfig
    ->save();
  $this
    ->drupalGet('views-bulk-operations-test');

  // Log in as a user with 'edit any page content' permission
  // to have access to perform the test operation.
  $admin_user = $this
    ->drupalCreateUser([
    'edit any page content',
  ]);
  $this
    ->drupalLogin($admin_user);

  // Check if we're on the confirmation form and if the overridden label
  // is displayed.
  $selection = [
    0,
    2,
    3,
  ];
  $label = $preconfig['label_override'];
  $this
    ->executeAction('views-bulk-operations-test', t('Simple test action'), $selection);
  $assertSession
    ->pageTextContains(sprintf('Are you sure you wish to perform "%s" action on %d entities?', $label, count($selection)));
}