mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
test: move RegisterUserProcessorTest
This commit is contained in:
parent
767949aefa
commit
0de6c7a132
@ -36,7 +36,6 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
),
|
),
|
||||||
new Post(
|
new Post(
|
||||||
uriTemplate: '/register',
|
uriTemplate: '/register',
|
||||||
routeName: 'user_register',
|
|
||||||
openapiContext: [
|
openapiContext: [
|
||||||
'summary' => 'Register a new user',
|
'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.',
|
'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.',
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Tests\Controller;
|
namespace App\Tests\State;
|
||||||
|
|
||||||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||||
use App\Factory\UserFactory;
|
use App\Factory\UserFactory;
|
||||||
@ -8,7 +8,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Zenstruck\Foundry\Test\Factories;
|
use Zenstruck\Foundry\Test\Factories;
|
||||||
|
|
||||||
final class RegistrationControllerTest extends ApiTestCase
|
final class RegisterUserProcessorTest extends ApiTestCase
|
||||||
{
|
{
|
||||||
use Factories;
|
use Factories;
|
||||||
|
|
||||||
@ -17,15 +17,15 @@ final class RegistrationControllerTest extends ApiTestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
RegistrationControllerTest::$container = RegistrationControllerTest::getContainer();
|
RegisterUserProcessorTest::$container = RegisterUserProcessorTest::getContainer();
|
||||||
RegistrationControllerTest::$entityManager = RegistrationControllerTest::$container->get(EntityManagerInterface::class);
|
RegisterUserProcessorTest::$entityManager = RegisterUserProcessorTest::$container->get(EntityManagerInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRegister(): void
|
public function testRegister(): void
|
||||||
{
|
{
|
||||||
$testUser = UserFactory::createOne();
|
$testUser = UserFactory::createOne();
|
||||||
RegistrationControllerTest::$entityManager->remove($testUser);
|
RegisterUserProcessorTest::$entityManager->remove($testUser);
|
||||||
RegistrationControllerTest::$entityManager->flush();
|
RegisterUserProcessorTest::$entityManager->flush();
|
||||||
|
|
||||||
$client = $this->createClient();
|
$client = $this->createClient();
|
||||||
$client->request('POST', '/api/register', [
|
$client->request('POST', '/api/register', [
|
||||||
@ -47,7 +47,7 @@ final class RegistrationControllerTest extends ApiTestCase
|
|||||||
'password' => 'MySuperPassword123',
|
'password' => 'MySuperPassword123',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->assertResponseStatusCodeSame(400);
|
$this->assertResponseStatusCodeSame(422);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRegisterEmptyPassword(): void
|
public function testRegisterEmptyPassword(): void
|
||||||
@ -59,7 +59,7 @@ final class RegistrationControllerTest extends ApiTestCase
|
|||||||
'password' => '',
|
'password' => '',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->assertResponseStatusCodeSame(400);
|
$this->assertResponseStatusCodeSame(422);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRegisterWeakPassword(): void
|
public function testRegisterWeakPassword(): void
|
||||||
@ -71,6 +71,6 @@ final class RegistrationControllerTest extends ApiTestCase
|
|||||||
'password' => '123',
|
'password' => '123',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->assertResponseStatusCodeSame(400);
|
$this->assertResponseStatusCodeSame(422);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user