Add Event entity, create event page, and custom WYSIWYG editor component
- Create Event entity with fields: account, title, description (text), startAt, endAt, address, zipcode, city, eventMainPicture (VichUploader), isOnline, createdAt, updatedAt
- Create EventRepository
- Add migration for event table with all columns
- Add "Creer un evenement" button on account events tab
- Add create event page (/mon-compte/evenement/creer) with full form
- Build custom web component <e-ticket-editor> WYSIWYG editor:
- Toolbar: bold, italic, underline, paragraph, bullet list, remove formatting
- contentEditable div with HTML sync to hidden textarea
- HTML sanitizer (strips disallowed tags, XSS safe)
- Neo-brutalist CSS styling
- CSP compliant (no inline styles)
- Register editor in app.js via customElements.define
- Add editor CSS in app.scss
- Add 16 Event entity tests (all fields + isOnline + picture upload + updatedAt)
- Add 16 editor JS tests (sanitizer + custom element lifecycle)
- Add 3 AccountController tests (create event page, submit, access control)
- Update placeholders to generic examples (no association-specific data)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 12:49:24 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
|
|
|
|
|
|
use App\Entity\Event;
|
|
|
|
|
use App\Entity\User;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
use Symfony\Component\HttpFoundation\File\File;
|
|
|
|
|
|
|
|
|
|
class EventTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
public function testNewEventHasNullId(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertNull($event->getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCreatedAtIsSetOnConstruction(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertInstanceOf(\DateTimeImmutable::class, $event->getCreatedAt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetAccount(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$user = new User();
|
|
|
|
|
$user->setEmail('orga@example.com');
|
|
|
|
|
$user->setFirstName('Test');
|
|
|
|
|
$user->setLastName('Orga');
|
|
|
|
|
$user->setPassword('hashed');
|
|
|
|
|
|
|
|
|
|
$result = $event->setAccount($user);
|
|
|
|
|
|
|
|
|
|
self::assertSame($user, $event->getAccount());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetTitle(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setTitle('Brocante de printemps 2026');
|
|
|
|
|
|
|
|
|
|
self::assertSame('Brocante de printemps 2026', $event->getTitle());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetStartAt(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$date = new \DateTimeImmutable('2026-06-15 10:00:00');
|
|
|
|
|
$result = $event->setStartAt($date);
|
|
|
|
|
|
|
|
|
|
self::assertSame($date, $event->getStartAt());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetEndAt(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$date = new \DateTimeImmutable('2026-06-15 18:00:00');
|
|
|
|
|
$result = $event->setEndAt($date);
|
|
|
|
|
|
|
|
|
|
self::assertSame($date, $event->getEndAt());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetDescription(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setDescription('Grande brocante avec stands et animations.');
|
|
|
|
|
|
|
|
|
|
self::assertSame('Grande brocante avec stands et animations.', $event->getDescription());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDescriptionIsNullByDefault(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertNull($event->getDescription());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetAddress(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setAddress('12 avenue de la Republique');
|
|
|
|
|
|
|
|
|
|
self::assertSame('12 avenue de la Republique', $event->getAddress());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetZipcode(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setZipcode('75011');
|
|
|
|
|
|
|
|
|
|
self::assertSame('75011', $event->getZipcode());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetCity(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setCity('Paris');
|
|
|
|
|
|
|
|
|
|
self::assertSame('Paris', $event->getCity());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetEventMainPictureName(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setEventMainPictureName('event-photo.jpg');
|
|
|
|
|
|
|
|
|
|
self::assertSame('event-photo.jpg', $event->getEventMainPictureName());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetEventMainPictureFileUpdatesTimestamp(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertNull($event->getUpdatedAt());
|
|
|
|
|
|
|
|
|
|
$file = $this->createMock(File::class);
|
|
|
|
|
$result = $event->setEventMainPictureFile($file);
|
|
|
|
|
|
|
|
|
|
self::assertSame($file, $event->getEventMainPictureFile());
|
|
|
|
|
self::assertInstanceOf(\DateTimeImmutable::class, $event->getUpdatedAt());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testIsOnlineDefaultFalse(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertFalse($event->isOnline());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetIsOnline(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setIsOnline(true);
|
|
|
|
|
|
|
|
|
|
self::assertTrue($event->isOnline());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 17:54:02 +01:00
|
|
|
public function testGetSlug(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$event->setTitle('Brocante de printemps 2026');
|
|
|
|
|
self::assertSame('brocante-de-printemps-2026', $event->getSlug());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetSlugEmpty(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertSame('evenement', $event->getSlug());
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-20 17:06:03 +01:00
|
|
|
public function testIsSecretDefaultFalse(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
self::assertFalse($event->isSecret());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSetAndGetIsSecret(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$result = $event->setIsSecret(true);
|
|
|
|
|
|
|
|
|
|
self::assertTrue($event->isSecret());
|
|
|
|
|
self::assertSame($event, $result);
|
|
|
|
|
}
|
|
|
|
|
|
Add Event entity, create event page, and custom WYSIWYG editor component
- Create Event entity with fields: account, title, description (text), startAt, endAt, address, zipcode, city, eventMainPicture (VichUploader), isOnline, createdAt, updatedAt
- Create EventRepository
- Add migration for event table with all columns
- Add "Creer un evenement" button on account events tab
- Add create event page (/mon-compte/evenement/creer) with full form
- Build custom web component <e-ticket-editor> WYSIWYG editor:
- Toolbar: bold, italic, underline, paragraph, bullet list, remove formatting
- contentEditable div with HTML sync to hidden textarea
- HTML sanitizer (strips disallowed tags, XSS safe)
- Neo-brutalist CSS styling
- CSP compliant (no inline styles)
- Register editor in app.js via customElements.define
- Add editor CSS in app.scss
- Add 16 Event entity tests (all fields + isOnline + picture upload + updatedAt)
- Add 16 editor JS tests (sanitizer + custom element lifecycle)
- Add 3 AccountController tests (create event page, submit, access control)
- Update placeholders to generic examples (no association-specific data)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 12:49:24 +01:00
|
|
|
public function testSetEventMainPictureFileNullDoesNotUpdateTimestamp(): void
|
|
|
|
|
{
|
|
|
|
|
$event = new Event();
|
|
|
|
|
$event->setEventMainPictureFile(null);
|
|
|
|
|
|
|
|
|
|
self::assertNull($event->getUpdatedAt());
|
|
|
|
|
self::assertNull($event->getEventMainPictureFile());
|
|
|
|
|
}
|
|
|
|
|
}
|