Skip to content
Snippets Groups Projects
Commit d00474ba authored by Camille Simiand's avatar Camille Simiand
Browse files

Add functional tests

parent 7d279ea4
No related branches found
No related tags found
1 merge request!19Add a redirection to capsule_list in registration controller
......@@ -2,6 +2,7 @@
namespace App\Tests\Controller;
use App\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DomCrawler\Form;
......
......@@ -77,6 +77,30 @@ class RegistrationControllerTest extends WebTestCase
$this->assertResponseIsSuccessful('Once the user has validated his email, he should be on the login page');
}
public function testAnAuthenticatedUserShouldNotBeAbleToAccessTheRegisterPage(): void
{
$client = static::createClient();
$userRepository = static::getContainer()->get(UserRepository::class);
$testUser = $userRepository->findOneByEmail('defaultUser@localhost.com');
$client->loginUser($testUser);
$client->request('GET', '/register');
$this->assertResponseRedirects('/my_capsules', 302);
}
public function testAnAuthenticatedUserShouldNotBeAbleToAccessTheLoginPage(): void
{
$client = static::createClient();
$userRepository = static::getContainer()->get(UserRepository::class);
$testUser = $userRepository->findOneByEmail('defaultUser@localhost.com');
$client->loginUser($testUser);
$client->request('GET', '/login');
$this->assertResponseRedirects('/my_capsules', 302);
}
/**
* @param string $userEmail The registered user email
* @return RawMessage The email message sent to the user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment