public function ViewAjaxTest::testNonAjaxViewViaAjax in Drupal 9
Same name and namespace in other branches
- 8 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()
Ensures that non-ajax view cannot be accessed via an ajax HTTP request.
File
- core/
modules/ views/ tests/ src/ Functional/ ViewAjaxTest.php, line 49
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());
}