public function JsonApiRegressionTest::testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964 in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964()
- 9 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964()
Ensures GETting node collection + hook_node_grants() implementations works.
See also
https://www.drupal.org/project/drupal/issues/2984964
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiRegressionTest.php, line 316
Class
- JsonApiRegressionTest
- JSON:API regression tests.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964() {
// Set up data model.
$this
->assertTrue($this->container
->get('module_installer')
->install([
'node_access_test',
], TRUE), 'Installed modules.');
node_access_rebuild();
$this
->rebuildAll();
// Create data.
Node::create([
'title' => 'test article',
'type' => 'article',
])
->save();
// Test.
$user = $this
->drupalCreateUser([
'access content',
]);
$response = $this
->request('GET', Url::fromUri('internal:/jsonapi/node/article'), [
RequestOptions::AUTH => [
$user
->getAccountName(),
$user->pass_raw,
],
]);
$this
->assertSame(200, $response
->getStatusCode());
$this
->assertContains('user.node_grants:view', explode(' ', $response
->getHeader('X-Drupal-Cache-Contexts')[0]));
}