test: move RegisterUserProcessorTest

This commit is contained in:
Maël Gangloff 2025-12-11 10:32:29 +01:00
parent 767949aefa
commit 0de6c7a132
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
2 changed files with 9 additions and 10 deletions

View File

@ -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.',

View File

@ -1,6 +1,6 @@
<?php
namespace App\Tests\Controller;
namespace App\Tests\State;
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
use App\Factory\UserFactory;
@ -8,7 +8,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Zenstruck\Foundry\Test\Factories;
final class RegistrationControllerTest extends ApiTestCase
final class RegisterUserProcessorTest extends ApiTestCase
{
use Factories;
@ -17,15 +17,15 @@ final class RegistrationControllerTest extends ApiTestCase
protected function setUp(): void
{
RegistrationControllerTest::$container = RegistrationControllerTest::getContainer();
RegistrationControllerTest::$entityManager = RegistrationControllerTest::$container->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);
}
}