refactor: rebrand project to CRM SITECONSEIL (SARL SITECONSEIL)
- 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>
2026-04-02 18:48:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Tests\MessageHandler;
|
|
|
|
|
|
|
|
|
|
use App\Entity\AnalyticsEvent;
|
|
|
|
|
use App\Entity\AnalyticsUniqId;
|
|
|
|
|
use App\Entity\User;
|
|
|
|
|
use App\Message\AnalyticsMessage;
|
|
|
|
|
use App\MessageHandler\AnalyticsMessageHandler;
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
|
|
class AnalyticsMessageHandlerTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
private EntityManagerInterface $em;
|
|
|
|
|
private AnalyticsMessageHandler $handler;
|
|
|
|
|
|
|
|
|
|
protected function setUp(): void
|
|
|
|
|
{
|
|
|
|
|
$this->em = $this->createMock(EntityManagerInterface::class);
|
|
|
|
|
$this->handler = new AnalyticsMessageHandler($this->em);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvokeVisitorNotFound(): void
|
|
|
|
|
{
|
|
|
|
|
$repository = $this->createStub(EntityRepository::class);
|
|
|
|
|
$repository->method('findOneBy')->willReturn(null);
|
|
|
|
|
|
fix: supprimer toutes les deprecations PHPUnit (21 → 0)
Deprecation corrigee: "The any() invoked count expectation is deprecated"
- Remplacement de ->expects(\$this->any())->method() par ->method()
sur les stubs dans 6 fichiers:
tests/Controller/Admin/AdminControllersTest.php,
tests/Controller/SmallControllersTest.php,
tests/Controller/MainControllersTest.php,
tests/EventListener/ExceptionListenerTest.php,
tests/EventSubscriber/MessengerFailureSubscriberTest.php,
tests/MessageHandler/AnalyticsMessageHandlerTest.php
Deprecation corrigee: "Using with() without expects() is deprecated"
- Suppression des ->with() sur les stubs qui n'ont pas de expects()
dans SmallControllersTest, MessengerFailureSubscriberTest,
AnalyticsMessageHandlerTest
AdminControllersTest::testStatusIndex:
- EntityManagerInterface change de createMock a createStub
(pas d'expects() sur getRepository)
Resultat: 262 tests, 454 assertions, 0 failures, 0 deprecations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:48:48 +02:00
|
|
|
$this->em->method('getRepository')->willReturn($repository);
|
refactor: rebrand project to CRM SITECONSEIL (SARL SITECONSEIL)
- 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>
2026-04-02 18:48:25 +02:00
|
|
|
$this->em->expects($this->never())->method('flush');
|
|
|
|
|
|
|
|
|
|
$message = new AnalyticsMessage('uid', 'action');
|
|
|
|
|
($this->handler)($message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvokeSetUserSuccess(): void
|
|
|
|
|
{
|
|
|
|
|
$visitor = new AnalyticsUniqId();
|
|
|
|
|
$user = new User();
|
|
|
|
|
|
|
|
|
|
$visitorRepo = $this->createStub(EntityRepository::class);
|
|
|
|
|
$visitorRepo->method('findOneBy')->willReturn($visitor);
|
|
|
|
|
|
2026-04-02 23:53:03 +02:00
|
|
|
$userRepo = $this->createStub(EntityRepository::class);
|
fix: supprimer toutes les deprecations PHPUnit (21 → 0)
Deprecation corrigee: "The any() invoked count expectation is deprecated"
- Remplacement de ->expects(\$this->any())->method() par ->method()
sur les stubs dans 6 fichiers:
tests/Controller/Admin/AdminControllersTest.php,
tests/Controller/SmallControllersTest.php,
tests/Controller/MainControllersTest.php,
tests/EventListener/ExceptionListenerTest.php,
tests/EventSubscriber/MessengerFailureSubscriberTest.php,
tests/MessageHandler/AnalyticsMessageHandlerTest.php
Deprecation corrigee: "Using with() without expects() is deprecated"
- Suppression des ->with() sur les stubs qui n'ont pas de expects()
dans SmallControllersTest, MessengerFailureSubscriberTest,
AnalyticsMessageHandlerTest
AdminControllersTest::testStatusIndex:
- EntityManagerInterface change de createMock a createStub
(pas d'expects() sur getRepository)
Resultat: 262 tests, 454 assertions, 0 failures, 0 deprecations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:48:48 +02:00
|
|
|
$userRepo->method('find')->willReturn($user);
|
refactor: rebrand project to CRM SITECONSEIL (SARL SITECONSEIL)
- 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>
2026-04-02 18:48:25 +02:00
|
|
|
|
|
|
|
|
$this->em->method('getRepository')->willReturnMap([
|
|
|
|
|
[AnalyticsUniqId::class, $visitorRepo],
|
|
|
|
|
[User::class, $userRepo],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->em->expects($this->once())->method('flush');
|
|
|
|
|
|
|
|
|
|
$message = new AnalyticsMessage('uid', 'set_user', ['userId' => 42]);
|
|
|
|
|
($this->handler)($message);
|
|
|
|
|
|
|
|
|
|
$this->assertSame($user, $visitor->getUser());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvokeSetUserNoUserId(): void
|
|
|
|
|
{
|
|
|
|
|
$visitor = new AnalyticsUniqId();
|
|
|
|
|
$visitorRepo = $this->createStub(EntityRepository::class);
|
|
|
|
|
$visitorRepo->method('findOneBy')->willReturn($visitor);
|
|
|
|
|
|
fix: supprimer toutes les deprecations PHPUnit (21 → 0)
Deprecation corrigee: "The any() invoked count expectation is deprecated"
- Remplacement de ->expects(\$this->any())->method() par ->method()
sur les stubs dans 6 fichiers:
tests/Controller/Admin/AdminControllersTest.php,
tests/Controller/SmallControllersTest.php,
tests/Controller/MainControllersTest.php,
tests/EventListener/ExceptionListenerTest.php,
tests/EventSubscriber/MessengerFailureSubscriberTest.php,
tests/MessageHandler/AnalyticsMessageHandlerTest.php
Deprecation corrigee: "Using with() without expects() is deprecated"
- Suppression des ->with() sur les stubs qui n'ont pas de expects()
dans SmallControllersTest, MessengerFailureSubscriberTest,
AnalyticsMessageHandlerTest
AdminControllersTest::testStatusIndex:
- EntityManagerInterface change de createMock a createStub
(pas d'expects() sur getRepository)
Resultat: 262 tests, 454 assertions, 0 failures, 0 deprecations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:48:48 +02:00
|
|
|
$this->em->method('getRepository')->willReturn($visitorRepo);
|
refactor: rebrand project to CRM SITECONSEIL (SARL SITECONSEIL)
- 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>
2026-04-02 18:48:25 +02:00
|
|
|
$this->em->expects($this->never())->method('flush');
|
|
|
|
|
|
|
|
|
|
$message = new AnalyticsMessage('uid', 'set_user', []);
|
|
|
|
|
($this->handler)($message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvokeSetUserNotFound(): void
|
|
|
|
|
{
|
|
|
|
|
$visitor = new AnalyticsUniqId();
|
|
|
|
|
$visitorRepo = $this->createStub(EntityRepository::class);
|
|
|
|
|
$visitorRepo->method('findOneBy')->willReturn($visitor);
|
|
|
|
|
|
|
|
|
|
$userRepo = $this->createStub(EntityRepository::class);
|
|
|
|
|
$userRepo->method('find')->willReturn(null);
|
|
|
|
|
|
|
|
|
|
$this->em->method('getRepository')->willReturnMap([
|
|
|
|
|
[AnalyticsUniqId::class, $visitorRepo],
|
|
|
|
|
[User::class, $userRepo],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$this->em->expects($this->never())->method('flush');
|
|
|
|
|
|
|
|
|
|
$message = new AnalyticsMessage('uid', 'set_user', ['userId' => 999]);
|
|
|
|
|
($this->handler)($message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvokePageView(): void
|
|
|
|
|
{
|
|
|
|
|
$visitor = new AnalyticsUniqId();
|
|
|
|
|
$visitorRepo = $this->createStub(EntityRepository::class);
|
|
|
|
|
$visitorRepo->method('findOneBy')->willReturn($visitor);
|
|
|
|
|
|
fix: supprimer toutes les deprecations PHPUnit (21 → 0)
Deprecation corrigee: "The any() invoked count expectation is deprecated"
- Remplacement de ->expects(\$this->any())->method() par ->method()
sur les stubs dans 6 fichiers:
tests/Controller/Admin/AdminControllersTest.php,
tests/Controller/SmallControllersTest.php,
tests/Controller/MainControllersTest.php,
tests/EventListener/ExceptionListenerTest.php,
tests/EventSubscriber/MessengerFailureSubscriberTest.php,
tests/MessageHandler/AnalyticsMessageHandlerTest.php
Deprecation corrigee: "Using with() without expects() is deprecated"
- Suppression des ->with() sur les stubs qui n'ont pas de expects()
dans SmallControllersTest, MessengerFailureSubscriberTest,
AnalyticsMessageHandlerTest
AdminControllersTest::testStatusIndex:
- EntityManagerInterface change de createMock a createStub
(pas d'expects() sur getRepository)
Resultat: 262 tests, 454 assertions, 0 failures, 0 deprecations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:48:48 +02:00
|
|
|
$this->em->method('getRepository')->willReturn($visitorRepo);
|
refactor: rebrand project to CRM SITECONSEIL (SARL SITECONSEIL)
- 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>
2026-04-02 18:48:25 +02:00
|
|
|
|
|
|
|
|
$this->em->expects($this->once())->method('persist')->with($this->isInstanceOf(AnalyticsEvent::class));
|
|
|
|
|
$this->em->expects($this->once())->method('flush');
|
|
|
|
|
|
|
|
|
|
$payload = [
|
|
|
|
|
'url' => '/test',
|
|
|
|
|
'title' => 'Test Title',
|
|
|
|
|
'referrer' => 'http://google.com'
|
|
|
|
|
];
|
|
|
|
|
$message = new AnalyticsMessage('uid', 'page_view', $payload);
|
|
|
|
|
($this->handler)($message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testInvokePageViewEmptyPayload(): void
|
|
|
|
|
{
|
|
|
|
|
$visitor = new AnalyticsUniqId();
|
|
|
|
|
$visitorRepo = $this->createStub(EntityRepository::class);
|
|
|
|
|
$visitorRepo->method('findOneBy')->willReturn($visitor);
|
|
|
|
|
|
fix: supprimer toutes les deprecations PHPUnit (21 → 0)
Deprecation corrigee: "The any() invoked count expectation is deprecated"
- Remplacement de ->expects(\$this->any())->method() par ->method()
sur les stubs dans 6 fichiers:
tests/Controller/Admin/AdminControllersTest.php,
tests/Controller/SmallControllersTest.php,
tests/Controller/MainControllersTest.php,
tests/EventListener/ExceptionListenerTest.php,
tests/EventSubscriber/MessengerFailureSubscriberTest.php,
tests/MessageHandler/AnalyticsMessageHandlerTest.php
Deprecation corrigee: "Using with() without expects() is deprecated"
- Suppression des ->with() sur les stubs qui n'ont pas de expects()
dans SmallControllersTest, MessengerFailureSubscriberTest,
AnalyticsMessageHandlerTest
AdminControllersTest::testStatusIndex:
- EntityManagerInterface change de createMock a createStub
(pas d'expects() sur getRepository)
Resultat: 262 tests, 454 assertions, 0 failures, 0 deprecations
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:48:48 +02:00
|
|
|
$this->em->method('getRepository')->willReturn($visitorRepo);
|
refactor: rebrand project to CRM SITECONSEIL (SARL SITECONSEIL)
- 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>
2026-04-02 18:48:25 +02:00
|
|
|
$this->em->expects($this->once())->method('persist');
|
|
|
|
|
$this->em->expects($this->once())->method('flush');
|
|
|
|
|
|
|
|
|
|
$message = new AnalyticsMessage('uid', 'page_view');
|
|
|
|
|
($this->handler)($message);
|
|
|
|
|
}
|
|
|
|
|
}
|