You are here

public function ViewAjaxTest::testAjaxView in Drupal 8

Same name and namespace in other branches
  1. 9 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
    ->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'test_ajax_view', 'The view\'s ajaxViews array entry has the correct \'view_name\' key.');
  $this
    ->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'page_1', 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.');
}