You are here

public function AjaxTest::setUp in Search API 8

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/AjaxTest.php, line 40

Class

AjaxTest
Tests AJAX functionality in the Search API module.

Namespace

Drupal\Tests\search_api\FunctionalJavascript

Code

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

  // Create an article node type, if not already present.
  if (!NodeType::load('article')) {
    $this
      ->drupalCreateContentType([
      'type' => 'article',
      'name' => 'Article',
    ]);
  }

  // Create a page node type, if not already present.
  if (!NodeType::load('page')) {
    $this
      ->drupalCreateContentType([
      'type' => 'page',
      'name' => 'Page',
    ]);
  }

  // Do not use a batch for tracking the initial items after creating an
  // index when running the tests via the GUI. Otherwise, it seems Drupal's
  // Batch API gets confused and the test fails.
  if (!Utility::isRunningInCli()) {
    \Drupal::state()
      ->set('search_api_use_tracking_batch', FALSE);
  }
  $permissions = [
    'administer search_api',
    'access administration pages',
    'administer nodes',
    'bypass node access',
    'administer content types',
    'administer node fields',
  ];
  $this
    ->drupalLogin($this
    ->drupalCreateUser($permissions));
}