- Rename all references from E-Cosplay/Ecosplay to SITECONSEIL - Update entity from Association to SARL SITECONSEIL (Siret: 418664058) - Update address to 27 rue Le Serurier, 02100 Saint-Quentin - Update emails: contact@siteconseil.fr, rgpd@siteconseil.fr - Update hosting from GCP to OVHcloud (Roubaix, Gravelines, Strasbourg, Paris) - Update legal pages: mentions legales, CGV, RGPD, conformite, hebergement, cookies, CGU - Add tarifs page with tabs: Site Internet, E-Commerce, Nom de domaine, Esy-Mail, Esy-Mailer, Esy-Tchat, Esy-Meet, Esy-Defender - Add Discord webhook notification workflow - Disable deploy and sonarqube workflows - Update OAuth Keycloak realm to master - Update logo references to logo_facture.png - Remove forced image sizing in Liip Imagine filters - Update SonarQube project key and badge token - Update tribunal competent to Saint-Quentin - Move tarif tabs JS to app.js (CSP compliance) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Service;
|
|
|
|
use App\Service\UnsubscribeManager;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class UnsubscribeManagerTest extends TestCase
|
|
{
|
|
private string $tempDir;
|
|
private UnsubscribeManager $manager;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->tempDir = sys_get_temp_dir() . '/unsubscribe_test_' . uniqid();
|
|
mkdir($this->tempDir);
|
|
$this->manager = new UnsubscribeManager($this->tempDir, 'secret');
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
if (file_exists($this->tempDir . '/var/unsubscribed.json')) {
|
|
unlink($this->tempDir . '/var/unsubscribed.json');
|
|
}
|
|
if (is_dir($this->tempDir . '/var')) {
|
|
rmdir($this->tempDir . '/var');
|
|
}
|
|
rmdir($this->tempDir);
|
|
}
|
|
|
|
public function testGenerateToken(): void
|
|
{
|
|
$email = 'test@example.com';
|
|
$token = $this->manager->generateToken($email);
|
|
$this->assertNotEmpty($token);
|
|
$this->assertTrue($this->manager->isValidToken($email, $token));
|
|
$this->assertFalse($this->manager->isValidToken($email, 'wrong_token'));
|
|
}
|
|
|
|
public function testUnsubscribe(): void
|
|
{
|
|
$email = 'test@example.com';
|
|
$this->assertFalse($this->manager->isUnsubscribed($email));
|
|
|
|
$this->manager->unsubscribe($email);
|
|
$this->assertTrue($this->manager->isUnsubscribed($email));
|
|
|
|
// Re-unsubscribe should not duplicate or fail
|
|
$this->manager->unsubscribe($email);
|
|
$this->assertTrue($this->manager->isUnsubscribed($email));
|
|
}
|
|
|
|
public function testLoadEmptyHashes(): void
|
|
{
|
|
$this->assertFalse($this->manager->isUnsubscribed('none@example.com'));
|
|
}
|
|
}
|