protected function QuickEditEndPointAccessTest::assertAccessIsBlocked in Drupal 10
Same name and namespace in other branches
- 8 core/modules/quickedit/tests/src/Functional/QuickEditEndPointAccessTest.php \Drupal\Tests\quickedit\Functional\QuickEditEndPointAccessTest::assertAccessIsBlocked()
- 9 core/modules/quickedit/tests/src/Functional/QuickEditEndPointAccessTest.php \Drupal\Tests\quickedit\Functional\QuickEditEndPointAccessTest::assertAccessIsBlocked()
Asserts that access to the passed URL is blocked.
@internal
Parameters
string $url: The URL to check.
array $body: The payload to send with the request.
File
- core/
modules/ quickedit/ tests/ src/ Functional/ QuickEditEndPointAccessTest.php, line 82
Class
- QuickEditEndPointAccessTest
- Tests accessing the Quick Edit endpoints.
Namespace
Drupal\Tests\quickedit\FunctionalCode
protected function assertAccessIsBlocked(string $url, array $body) : void {
$client = $this
->getHttpClient();
$message = [
'message' => "The 'access in-place editing' permission is required.",
];
$response = $client
->post($url, [
RequestOptions::BODY => http_build_query($body),
RequestOptions::QUERY => [
MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax',
],
RequestOptions::COOKIES => $this
->getSessionCookies(),
RequestOptions::HEADERS => [
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded',
],
RequestOptions::HTTP_ERRORS => FALSE,
]);
$this
->assertEquals(403, $response
->getStatusCode());
$response_message = Json::decode($response
->getBody());
$this
->assertSame($message, $response_message);
}