public function PermissionsTest::testNoPermissions in GraphQL 8.3
Same name and namespace in other branches
- 8.4 tests/src/Kernel/Framework/PermissionsTest.php \Drupal\Tests\graphql\Kernel\Framework\PermissionsTest::testNoPermissions()
Test if a user without permissions doesn't have access to any query.
File
- tests/
src/ Kernel/ Framework/ PermissionsTest.php, line 47
Class
- PermissionsTest
- Test if query handling respects permissions properly.
Namespace
Drupal\Tests\graphql\Kernel\FrameworkCode
public function testNoPermissions() {
$this->accountProphecy
->hasPermission(Argument::any())
->willReturn(FALSE);
// Any query should fail.
$this
->assertEquals(403, $this
->query('query')
->getStatusCode());
$this
->assertEquals(403, $this
->persistedQuery('persisted:a')
->getStatusCode());
$batched = $this
->batchedQueries([
[
'query' => '{ root }',
],
[
'queryId' => 'persisted:a',
],
]);
// If all batched queries fail, 403 is returned.
$this
->assertEquals(403, $batched
->getStatusCode());
}