function ViewAjaxTest::testAjaxView

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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 38

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.