You are here

protected function ViewsBulkOperationsBulkFormTest::setUp 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::setUp()

Overrides BrowserTestBase::setUp

File

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

Class

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

Namespace

Drupal\Tests\views_bulk_operations\FunctionalJavaScript

Code

protected function setUp() {
  parent::setUp();

  // Create some nodes for testing.
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);
  for ($i = 0; $i <= self::TEST_NODE_COUNT; $i++) {
    $this
      ->drupalCreateNode([
      'type' => 'page',
      'title' => 'Title ' . $i,
    ]);
  }
  $admin_user = $this
    ->drupalCreateUser([
    'edit any page content',
    'create page content',
    'delete any page content',
  ]);
  $this
    ->drupalLogin($admin_user);
  $this->assertSession = $this
    ->assertSession();
  $this->page = $this
    ->getSession()
    ->getPage();
  $testViewConfig = \Drupal::service('config.factory')
    ->getEditable('views.view.' . self::TEST_VIEW_ID);

  // Get useful config data from the test view.
  $config_data = $testViewConfig
    ->getRawData();
  $this->testViewParams = [
    'items_per_page' => $config_data['display']['default']['display_options']['pager']['options']['items_per_page'],
    'path' => $config_data['display']['page_1']['display_options']['path'],
  ];

  // Enable AJAX on the view.
  $config_data['display']['default']['display_options']['use_ajax'] = TRUE;
  $testViewConfig
    ->setData($config_data);
  $testViewConfig
    ->save();
  $this
    ->drupalGet('/' . $this->testViewParams['path']);
}