diff --git a/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php b/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php index c187b65..aa1bd70 100644 --- a/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php +++ b/core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php @@ -94,6 +94,7 @@ protected function getAuthenticationRequestOptions($method) { protected function assertResponseWhenMissingAuthentication(ResponseInterface $response) { // Requests needing cookie authentication but missing it results in a 403 // response. The cookie authentication mechanism sets no response message. + // @todo https://www.drupal.org/node/2847623 $this->assertResourceErrorResponse(403, FALSE, $response); } diff --git a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php index 7c7836b..e6ba5bd 100644 --- a/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/EntityResource/EntityTest/EntityTestResourceTestBase.php @@ -131,6 +131,7 @@ protected function getExpectedUnauthorizedAccessMessage($method) { if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) { return parent::getExpectedUnauthorizedAccessMessage($method); } + if ($method === 'GET') { return "The 'view test entity' permission is required."; } diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php index a7dacac..2674d70 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php @@ -210,7 +210,7 @@ protected function provisionResource($resource_type, $formats = [], $authenticat * The HTTP method (GET, POST, PATCH, DELETE). * * @return string - * The Error string. + * The error string. */ abstract protected function getExpectedUnauthorizedAccessMessage($method); @@ -222,7 +222,7 @@ protected function provisionResource($resource_type, $formats = [], $authenticat * The HTTP method (GET, POST, PATCH, DELETE). * * @return string - * The Error string. + * The error string. */ abstract protected function getExpectedBcUnauthorizedAccessMessage($method); diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php index e96ba29..5b96b19 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\Core\Access; -use Drupal\Core\Access\AccessResultForbidden; use Drupal\Core\Access\AccessResultNeutral; use Drupal\Tests\UnitTestCase; @@ -19,9 +18,8 @@ class AccessResultNeutralTest extends UnitTestCase { * @covers ::getReason */ public function testConstruction() { - $a = new AccessResultNeutral(); - $this->assertEquals(NULL, $a->getReason()); + $this->assertNull($a->getReason()); $reason = $this->getRandomGenerator()->string(); $b = new AccessResultNeutral($reason); diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php index 487ab0e..6f18648 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php @@ -174,9 +174,9 @@ public function testAccessConditionallyForbidden() { * @covers ::andIf */ public function testAndIf() { - $neutral = AccessResult::neutral(); + $neutral = AccessResult::neutral('neutral message'); $allowed = AccessResult::allowed(); - $forbidden = AccessResult::forbidden(); + $forbidden = AccessResult::forbidden('forbidden message'); $unused_access_result_due_to_lazy_evaluation = $this->getMock('\Drupal\Core\Access\AccessResultInterface'); $unused_access_result_due_to_lazy_evaluation->expects($this->never()) ->method($this->anything()); @@ -193,6 +193,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertFalse($access->isForbidden()); $this->assertTrue($access->isNeutral()); + $this->assertEquals('neutral message', $access->getReason()); $this->assertDefaultCacheability($access); // ALLOWED && FORBIDDEN === FORBIDDEN. @@ -200,6 +201,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // NEUTRAL && ALLOW == NEUTRAL @@ -207,6 +209,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertFalse($access->isForbidden()); $this->assertTrue($access->isNeutral()); + $this->assertEquals('neutral message', $access->getReason()); $this->assertDefaultCacheability($access); // NEUTRAL && NEUTRAL === NEUTRAL. @@ -214,6 +217,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertFalse($access->isForbidden()); $this->assertTrue($access->isNeutral()); + $this->assertEquals('neutral message', $access->getReason()); $this->assertDefaultCacheability($access); // NEUTRAL && FORBIDDEN === FORBIDDEN. @@ -221,6 +225,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN && ALLOWED = FORBIDDEN @@ -228,6 +233,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN && NEUTRAL = FORBIDDEN @@ -235,6 +241,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN && FORBIDDEN = FORBIDDEN @@ -242,6 +249,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN && * === FORBIDDEN: lazy evaluation verification. @@ -249,6 +257,7 @@ public function testAndIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); } @@ -256,9 +265,9 @@ public function testAndIf() { * @covers ::orIf */ public function testOrIf() { - $neutral = AccessResult::neutral(); + $neutral = AccessResult::neutral('neutral message'); $allowed = AccessResult::allowed(); - $forbidden = AccessResult::forbidden(); + $forbidden = AccessResult::forbidden('forbidden message'); $unused_access_result_due_to_lazy_evaluation = $this->getMock('\Drupal\Core\Access\AccessResultInterface'); $unused_access_result_due_to_lazy_evaluation->expects($this->never()) ->method($this->anything()); @@ -282,6 +291,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // NEUTRAL || NEUTRAL === NEUTRAL. @@ -289,6 +299,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertFalse($access->isForbidden()); $this->assertTrue($access->isNeutral()); + $this->assertEquals('neutral message', $access->getReason()); $this->assertDefaultCacheability($access); // NEUTRAL || ALLOWED === ALLOWED. @@ -303,6 +314,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN || ALLOWED === FORBIDDEN. @@ -310,6 +322,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN || NEUTRAL === FORBIDDEN. @@ -317,6 +330,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN || FORBIDDEN === FORBIDDEN. @@ -324,6 +338,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); // FORBIDDEN || * === FORBIDDEN. @@ -331,6 +346,7 @@ public function testOrIf() { $this->assertFalse($access->isAllowed()); $this->assertTrue($access->isForbidden()); $this->assertFalse($access->isNeutral()); + $this->assertEquals('forbidden message', $access->getReason()); $this->assertDefaultCacheability($access); }