diff --git a/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php b/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php index 545516a..762e2f5 100644 --- a/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/UserRegistrationResource.php @@ -169,7 +169,7 @@ public function routes() { // Restrict the incoming HTTP Content-type header to the known serialization // formats. - $route->addRequirements(['_content_type_format' => implode('|', $this->serializerFormats)])); + $route->addRequirements(['_content_type_format' => implode('|', $this->serializerFormats)]); $collection->add("$this->pluginId", $route); return $collection; diff --git a/core/modules/rest/tests/src/Unit/UserRegistrationResourceTest.php b/core/modules/rest/tests/src/Unit/UserRegistrationResourceTest.php index 2facc31..6ac54f0 100644 --- a/core/modules/rest/tests/src/Unit/UserRegistrationResourceTest.php +++ b/core/modules/rest/tests/src/Unit/UserRegistrationResourceTest.php @@ -149,6 +149,8 @@ public function testValidate() { } /** + * Tests that error validation is thrown as expected. + * * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @expectedException UserRegistrationResourceTest::ERROR_MESSAGE */ @@ -191,11 +193,13 @@ public function testFailedValidate() { ->will($this->returnValue($violations)); $method = $this->getProtectedMethod('validate'); - // No exception is thrown. + $method->invoke($this->testClass, $entity); } /** + * Tests that an exception is thrown when no data provided for the account. + * * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException * @expectedExceptionMessage No user account data for registration received. */ @@ -204,8 +208,10 @@ public function testEmptyPost() { } /** + * Tests that only new user accounts can be registered. + * * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException - * @expectedExceptionMessage Only new user accounts can be registered. + * @expectedExceptionMessage An ID has been set and only new user accounts can be registered. */ public function testExistedEntityPost() { $entity = $this->getMockBuilder(User::class) @@ -220,6 +226,8 @@ public function testExistedEntityPost() { } /** + * Tests that admin permissions are required to register a user account. + * * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @expectedExceptionMessage Only administrators can register users. */ @@ -245,6 +253,8 @@ public function testRegistrationAdminOnlyPost() { } /** + * Tests that only anonymous users can register users. + * * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @expectedExceptionMessage Only anonymous users can register users. */ @@ -267,6 +277,8 @@ public function testRegistrationAnonymousOnlyPost() { } /** + * Tests access denied on creating field. + * * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @expectedExceptionMessage Access denied on creating field 'test_field'. */