You are here

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

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

Tests the VBO bulk form with dynamic insertion.

Nodes inserted right after selecting targeted row(s) of the view.

File

tests/src/FunctionalJavascript/ViewsBulkOperationsBulkFormTest.php, line 163

Class

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

Namespace

Drupal\Tests\views_bulk_operations\FunctionalJavaScript

Code

public function testViewsBulkOperationsWithDynamicInsertion() {
  $this->selectedIndexes = [
    0,
    1,
    3,
  ];
  foreach ($this->selectedIndexes as $selected_index) {
    $this->page
      ->checkField('views_bulk_operations_bulk_form[' . $selected_index . ']');
  }

  // Insert nodes.
  $nodes = [];
  for ($i = 100; $i < 100 + self::TEST_NODE_COUNT; $i++) {
    $nodes[] = $this
      ->drupalCreateNode([
      'type' => 'page',
      'title' => 'Title ' . $i,
    ]);
  }
  $this->page
    ->pressButton('Simple test action');
  foreach ($this->selectedIndexes as $index) {
    $this->assertSession
      ->pageTextContains(sprintf('Test action (preconfig: Test setting, label: Title %s)', self::TEST_NODE_COUNT - $index));
  }
  $this->assertSession
    ->pageTextContains(sprintf('Action processing results: Test (%s)', count($this->selectedIndexes)));
}