You are here

public function ViewAjaxTest::testAjaxView in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/ViewAjaxTest.php \Drupal\Tests\views\Functional\ViewAjaxTest::testAjaxView()
  2. 10 core/modules/views/tests/src/Functional/ViewAjaxTest.php \Drupal\Tests\views\Functional\ViewAjaxTest::testAjaxView()

Tests an ajax view.

File

core/modules/views/tests/src/Functional/ViewAjaxTest.php, line 35

Class

ViewAjaxTest
Tests the ajax view functionality.

Namespace

Drupal\Tests\views\Functional

Code

public function testAjaxView() {
  $this
    ->drupalGet('test_ajax_view');
  $drupal_settings = $this
    ->getDrupalSettings();
  $this
    ->assertTrue(isset($drupal_settings['views']['ajax_path']), 'The Ajax callback path is set in drupalSettings.');
  $this
    ->assertCount(1, $drupal_settings['views']['ajaxViews']);
  $view_entry = array_keys($drupal_settings['views']['ajaxViews'])[0];
  $this
    ->assertEquals('test_ajax_view', $drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'The view\'s ajaxViews array entry has the correct \'view_name\' key.');
  $this
    ->assertEquals('page_1', $drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.');
}