New tests (47 added, 622 total): - MonitorMessengerCommand: no failures, failures with email, null error, multiple (4) - UnsubscribeController: unsubscribe with invitations refused + admin notified (1) - AdminController: suspend/reactivate orga, orders page with filters, logs, invite orga submit/empty, delete/resend invitation, export CSV/PDF (13) - AccountController: export CSV/PDF, getAllowedBilletTypes (free/basic/sur-mesure/null), billet type restriction, finance stats all statuses, soldCounts (9) - HomeController: city filter, date filter, all filters combined, stock route (4) - OrderController: event ended, invalid cart JSON, invalid email, stock zero (4) - MailerService: getAdminEmail, getAdminFrom (2) - JS: comment node, tabs missing panel/id/parent, cart stock polling edge cases (10) Accessibility fixes: - events.html.twig: add for/id on search, city, date labels - admin/orders.html.twig: add for/id on search, status labels Code quality: - cart.js: remove dead ternaire branch (max > 10 always plural) - tabs.js: use optional chaining for tablist?.setAttribute - MeilisearchConsistencyCommand: extract diffAndReport() (was duplicated 3x) - Email templates: extract _order_items_table.html.twig partial - SonarQube: exclude src/Entity/** from CPD Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
2.4 KiB
PHP
76 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Controller;
|
|
|
|
use App\Entity\OrganizerInvitation;
|
|
use App\Service\MailerService;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
class UnsubscribeControllerTest extends WebTestCase
|
|
{
|
|
public function testInvalidTokenReturns404(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/unsubscribe/invalid-base64');
|
|
|
|
self::assertResponseStatusCodeSame(404);
|
|
}
|
|
|
|
public function testValidTokenShowsUnsubscribePage(): void
|
|
{
|
|
$client = static::createClient();
|
|
$token = base64_encode('user@example.com');
|
|
$client->request('GET', '/unsubscribe/'.$token);
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testPostConfirmsUnsubscribe(): void
|
|
{
|
|
$client = static::createClient();
|
|
$token = base64_encode('user@example.com');
|
|
$client->request('POST', '/unsubscribe/'.$token);
|
|
|
|
self::assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testPostRefusesInvitationsAndNotifiesAdmin(): void
|
|
{
|
|
$client = static::createClient();
|
|
$em = static::getContainer()->get(EntityManagerInterface::class);
|
|
|
|
$email = 'unsub-invite-'.uniqid().'@example.com';
|
|
|
|
$invitation = new OrganizerInvitation();
|
|
$invitation->setCompanyName('Asso Unsub');
|
|
$invitation->setFirstName('Test');
|
|
$invitation->setLastName('Unsub');
|
|
$invitation->setEmail($email);
|
|
$invitation->setStatus(OrganizerInvitation::STATUS_SENT);
|
|
$em->persist($invitation);
|
|
$em->flush();
|
|
|
|
$mailer = $this->createMock(MailerService::class);
|
|
$mailer->expects(self::once())->method('sendEmail')->with(
|
|
$this->anything(),
|
|
$this->stringContains('Desinscription'),
|
|
$this->stringContains($email),
|
|
null,
|
|
null,
|
|
false,
|
|
);
|
|
static::getContainer()->set(MailerService::class, $mailer);
|
|
|
|
$token = base64_encode($email);
|
|
$client->request('POST', '/unsubscribe/'.$token);
|
|
|
|
self::assertResponseIsSuccessful();
|
|
|
|
$freshEm = static::getContainer()->get(EntityManagerInterface::class);
|
|
$updated = $freshEm->getRepository(OrganizerInvitation::class)->find($invitation->getId());
|
|
self::assertSame(OrganizerInvitation::STATUS_REFUSED, $updated->getStatus());
|
|
self::assertNotNull($updated->getRespondedAt());
|
|
}
|
|
}
|