function ViewAjaxTest::testNonAjaxViewViaAjax
Same name in other branches
- 8.9.x core/modules/views/tests/src/Functional/ViewAjaxTest.php \Drupal\Tests\views\Functional\ViewAjaxTest::testNonAjaxViewViaAjax()
- 10 core/modules/views/tests/src/Functional/ViewAjaxTest.php \Drupal\Tests\views\Functional\ViewAjaxTest::testNonAjaxViewViaAjax()
- 11.x core/modules/views/tests/src/Functional/ViewAjaxTest.php \Drupal\Tests\views\Functional\ViewAjaxTest::testNonAjaxViewViaAjax()
Ensures that non-ajax view cannot be accessed via an ajax HTTP request.
File
-
core/
modules/ views/ tests/ src/ Functional/ ViewAjaxTest.php, line 52
Class
- ViewAjaxTest
- Tests the ajax view functionality.
Namespace
Drupal\Tests\views\FunctionalCode
public function testNonAjaxViewViaAjax() {
$client = $this->getHttpClient();
$response = $client->request('POST', $this->buildUrl('views/ajax'), [
'form_params' => [
'view_name' => 'test_ajax_view',
'view_display_id' => 'default',
],
'query' => [
MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax',
],
]);
$this->assertEquals(200, $response->getStatusCode());
$response = $client->request('POST', $this->buildUrl('views/ajax'), [
'form_params' => [
'view_name' => 'test_view',
'view_display_id' => 'default',
],
'query' => [
MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax',
],
'http_errors' => FALSE,
]);
$this->assertEquals(403, $response->getStatusCode());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.