function JsonApiRegressionTest::testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964()
- 10 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2984964()
- 11.x 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 314
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]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.