From 0de6c7a132e42c2289e289e29a9849b5a4e20c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Thu, 11 Dec 2025 10:32:29 +0100 Subject: [PATCH] test: move RegisterUserProcessorTest --- src/Entity/User.php | 1 - .../RegisterUserProcessorTest.php} | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) rename tests/{Controller/RegistrationControllerTest.php => State/RegisterUserProcessorTest.php} (74%) diff --git a/src/Entity/User.php b/src/Entity/User.php index 8c555a2..aaf6318 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -36,7 +36,6 @@ use Symfony\Component\Validator\Constraints as Assert; ), new Post( uriTemplate: '/register', - routeName: 'user_register', openapiContext: [ 'summary' => 'Register a new user', 'description' => 'If the server configuration allows it, this endpoint enables the registration of a new user. Depending on the server configuration, a confirmation email may be sent to the provided email address so that the user can verify their email address.', diff --git a/tests/Controller/RegistrationControllerTest.php b/tests/State/RegisterUserProcessorTest.php similarity index 74% rename from tests/Controller/RegistrationControllerTest.php rename to tests/State/RegisterUserProcessorTest.php index 893f81e..3b99ff3 100644 --- a/tests/Controller/RegistrationControllerTest.php +++ b/tests/State/RegisterUserProcessorTest.php @@ -1,6 +1,6 @@ get(EntityManagerInterface::class); + RegisterUserProcessorTest::$container = RegisterUserProcessorTest::getContainer(); + RegisterUserProcessorTest::$entityManager = RegisterUserProcessorTest::$container->get(EntityManagerInterface::class); } public function testRegister(): void { $testUser = UserFactory::createOne(); - RegistrationControllerTest::$entityManager->remove($testUser); - RegistrationControllerTest::$entityManager->flush(); + RegisterUserProcessorTest::$entityManager->remove($testUser); + RegisterUserProcessorTest::$entityManager->flush(); $client = $this->createClient(); $client->request('POST', '/api/register', [ @@ -47,7 +47,7 @@ final class RegistrationControllerTest extends ApiTestCase 'password' => 'MySuperPassword123', ], ]); - $this->assertResponseStatusCodeSame(400); + $this->assertResponseStatusCodeSame(422); } public function testRegisterEmptyPassword(): void @@ -59,7 +59,7 @@ final class RegistrationControllerTest extends ApiTestCase 'password' => '', ], ]); - $this->assertResponseStatusCodeSame(400); + $this->assertResponseStatusCodeSame(422); } public function testRegisterWeakPassword(): void @@ -71,6 +71,6 @@ final class RegistrationControllerTest extends ApiTestCase 'password' => '123', ], ]); - $this->assertResponseStatusCodeSame(400); + $this->assertResponseStatusCodeSame(422); } }