diff --git a/tests/Controller/RegistrationControllerTest.php b/tests/Controller/RegistrationControllerTest.php index e69de29..ad297b2 100644 --- a/tests/Controller/RegistrationControllerTest.php +++ b/tests/Controller/RegistrationControllerTest.php @@ -0,0 +1,78 @@ +get(EntityManagerInterface::class); + } + + public function testRegister(): void + { + $testUser = UserFactory::createOne(); + RegistrationControllerTest::$entityManager->remove($testUser); + RegistrationControllerTest::$entityManager->flush(); + + $client = $this->createClient(); + $client->request('POST', '/api/register', [ + 'json' => [ + 'email' => $testUser->getEmail(), + 'password' => $testUser->getPlainPassword(), + ], + ]); + $this->assertResponseIsSuccessful(); + $this->assertResponseStatusCodeSame(201); + } + + public function testRegisterEmptyEmail(): void + { + $client = $this->createClient(); + $client->request('POST', '/api/register', [ + 'json' => [ + 'email' => '', + 'password' => 'MySuperPassword123', + ], + ]); + $this->assertResponseStatusCodeSame(400); + } + + public function testRegisterEmptyPassword(): void + { + $client = $this->createClient(); + $client->request('POST', '/api/register', [ + 'json' => [ + 'email' => 'test@domainwatchdog.eu', + 'password' => '', + ], + ]); + $this->assertResponseStatusCodeSame(400); + } + + public function testRegisterWeakPassword(): void + { + $client = $this->createClient(); + $client->request('POST', '/api/register', [ + 'json' => [ + 'email' => 'test@domainwatchdog.eu', + 'password' => '123', + ], + ]); + $this->assertResponseStatusCodeSame(400); + } +}