.../EntityResource/Block/BlockResourceTestBase.php | 42 +++++++++------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php index 8c692b6..5ef4512 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/Block/BlockResourceTestBase.php @@ -23,7 +23,14 @@ * {@inheritdoc} */ protected function setUpAuthorization($method) { - $this->grantPermissionsToTestedRole(['administer blocks']); + switch ($method) { + case 'GET': + $this->entity->setVisibilityConfig('user_role', [])->save(); + break; + case 'POST': + $this->grantPermissionsToTestedRole(['administer blocks']); + break; + } } /** @@ -44,18 +51,14 @@ protected function createEntity() { // "render on a page" and 'view' as in "read the configuration". // This prevents that. // @todo Investigate further. - if ($this->account) { - $block->setVisibilityConfig('user_role', [ - 'id' => 'user_role', - 'roles' => [ - 'authenticated' => 'authenticated', - ], - 'negate' => FALSE, - 'context_mapping' => [ - 'user' => '@user.current_user_context:current_user', - ], - ]); - } + $block->setVisibilityConfig('user_role', [ + 'id' => 'user_role', + 'roles' => ['non-existing-role' => 'non-existing-role'], + 'negate' => FALSE, + 'context_mapping' => [ + 'user' => '@user.current_user_context:current_user', + ], + ]); $block->save(); return $block; @@ -86,19 +89,6 @@ protected function getExpectedNormalizedEntity() { ], 'visibility' => [], ]; - if ($this->account) { - $normalization['dependencies']['module'][] = 'user'; - $normalization['visibility']['user_role'] = [ - 'id' => 'user_role', - 'roles' => [ - 'authenticated' => 'authenticated', - ], - 'negate' => FALSE, - 'context_mapping' => [ - 'user' => '@user.current_user_context:current_user', - ], - ]; - } return $normalization; }