Files
e-ticket/tests/Controller/SecurityControllerTest.php
Serreau Jovann af8bbc24dc Add homepage, tarifs, legal pages, navbar, footer and full test coverage
- Homepage: hero, how it works (buyer/organizer), features, CTA
- Tarifs: 3 plans (Gratuit, Basique 10€, Sur-mesure), JSON-LD Product
- Legal pages: mentions legales, CGU (tabs buyer/organizer), CGV, RGPD, cookies, hosting
- Navbar: neubrutalism style, logo liip, mobile menu, SEO attributes
- Footer: contact, description, legal links, tarifs
- Sitemap: add /tarifs and /sitemap-orgas-{page}.xml
- Liip Imagine: remove S3, webp format on all filters
- Tests: full coverage for all controllers, services, repositories
- Fix CSP: replace inline onclick with data-tab JS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 00:01:58 +01:00

84 lines
2.1 KiB
PHP

<?php
namespace App\Tests\Controller;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class SecurityControllerTest extends WebTestCase
{
public function testLoginPageReturnsSuccess(): void
{
$client = static::createClient();
$client->request('GET', '/connexion');
self::assertResponseIsSuccessful();
}
public function testLoginRedirectsWhenAuthenticated(): void
{
$client = static::createClient();
$user = $this->createUser();
$client->loginUser($user);
$client->request('GET', '/connexion');
self::assertResponseRedirects();
}
public function testChangePasswordRedirectsWhenNotAuthenticated(): void
{
$client = static::createClient();
$client->request('GET', '/mot-de-passe');
self::assertResponseRedirects();
}
public function testChangePasswordReturnsSuccessWhenAuthenticated(): void
{
$client = static::createClient();
$user = $this->createUser();
$client->loginUser($user);
$client->request('GET', '/mot-de-passe');
self::assertResponseIsSuccessful();
}
public function testWellKnownChangePasswordWhenAuthenticated(): void
{
$client = static::createClient();
$user = $this->createUser();
$client->loginUser($user);
$client->request('GET', '/.well-known/change-password');
self::assertResponseIsSuccessful();
}
public function testLogoutThrowsLogicException(): void
{
$this->expectException(\LogicException::class);
$controller = new \App\Controller\SecurityController();
$controller->logout();
}
private function createUser(): User
{
$em = static::getContainer()->get(EntityManagerInterface::class);
$user = new User();
$user->setEmail('test-security-'.uniqid().'@example.com');
$user->setFirstName('Test');
$user->setLastName('User');
$user->setPassword('$2y$13$hashed');
$em->persist($user);
$em->flush();
return $user;
}
}