Remove events classes and code

This commit is contained in:
Claudio Zizza
2023-08-29 19:47:10 +02:00
parent 185afd4aa7
commit 19388a5d0a
18 changed files with 0 additions and 1066 deletions

View File

@@ -102,7 +102,6 @@ class Application
}
$dataLoader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../data'));
$dataLoader->load('events.yml');
$dataLoader->load('partners.yml');
$dataLoader->load('projects.yml');
$dataLoader->load('sponsors.yml');

View File

@@ -1,47 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Controllers;
use Doctrine\StaticWebsiteGenerator\Controller\Response;
use Doctrine\Website\Model\Event;
use Doctrine\Website\Repositories\EventRepository;
final class EventsController
{
/** @param EventRepository<Event> $eventRepository */
public function __construct(private EventRepository $eventRepository)
{
}
public function index(): Response
{
$upcomingEvents = $this->eventRepository->findUpcomingEvents();
$pastEvents = $this->eventRepository->findPastEvents();
return new Response([
'upcomingEvents' => $upcomingEvents,
'pastEvents' => $pastEvents,
]);
}
public function view(string $id, string $slug): Response
{
$event = $this->eventRepository->findOneById((int) $id);
return new Response(['event' => $event], '/event.html.twig');
}
public function cfp(string $id, string $slug): Response
{
$event = $this->eventRepository->findOneById((int) $id);
return new Response(['event' => $event], '/event-cfp.html.twig');
}
public function suggest(): Response
{
return new Response([]);
}
}

View File

@@ -1,153 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Hydrators;
use DateTimeImmutable;
use Doctrine\SkeletonMapper\ObjectManagerInterface;
use Doctrine\Website\Application;
use Doctrine\Website\Model\Address;
use Doctrine\Website\Model\DateTimeRange;
use Doctrine\Website\Model\Event;
use Doctrine\Website\Model\EventCfp;
use Doctrine\Website\Model\EventLocation;
use Doctrine\Website\Model\EventSchedule;
use Doctrine\Website\Model\EventSpeakers;
use Doctrine\Website\Model\EventSponsors;
use Doctrine\Website\Model\EventType;
use InvalidArgumentException;
use function current;
use function end;
use function sprintf;
/**
* @property int $id
* @property string $name
* @property string $slug
* @property string $type
* @property EventLocation|null $location
* @property string $sku
* @property string $joinUrl
* @property EventCfp $cfp
* @property EventSponsors $sponsors
* @property EventSpeakers $speakers
* @property EventSchedule $schedule
* @property DateTimeRange $dateTimeRange
* @property DateTimeRange $registrationDateTimeRange
* @property string $description
* @property float $price
* @template-extends ModelHydrator<Event>
*/
final class EventHydrator extends ModelHydrator
{
private const ENV_SKU_MAP = [
'dev' => 'test',
Application::ENV_PROD => Application::ENV_PROD,
Application::ENV_STAGING => 'test',
'test' => 'test',
];
public function __construct(
ObjectManagerInterface $objectManager,
private string $env,
) {
parent::__construct($objectManager);
}
/** @return class-string<Event> */
protected function getClassName(): string
{
return Event::class;
}
/** @param mixed[] $data */
protected function doHydrate(array $data): void
{
$this->id = (int) ($data['id'] ?? 0);
$this->type = (string) ($data['type'] ?? EventType::WEBINAR);
if ($this->type === EventType::CONFERENCE) {
if (! isset($data['location'])) {
throw new InvalidArgumentException(
sprintf('Event type of "%s" must provide a "location" field.', $this->type),
);
}
$this->location = new EventLocation(
(string) ($data['location']['name'] ?? ''),
new Address(
(string) ($data['location']['address']['line1'] ?? ''),
(string) ($data['location']['address']['line2'] ?? ''),
(string) ($data['location']['address']['city'] ?? ''),
(string) ($data['location']['address']['state'] ?? ''),
(string) ($data['location']['address']['zipCode'] ?? ''),
(string) ($data['location']['address']['countryCode'] ?? ''),
),
);
}
if (isset($data['sku'])) {
if (! isset(self::ENV_SKU_MAP[$this->env])) {
throw new InvalidArgumentException(sprintf('Invalid env "%s".', $this->env));
}
$skuKey = self::ENV_SKU_MAP[$this->env];
if (! isset($data['sku'][$skuKey])) {
throw new InvalidArgumentException(
sprintf('Sku key with "%s" does not exist.', $skuKey),
);
}
$this->sku = (string) ($data['sku'][$skuKey] ?? '');
} else {
$this->sku = '';
}
$this->name = (string) ($data['name'] ?? '');
$this->slug = (string) ($data['slug'] ?? '');
$this->joinUrl = (string) ($data['joinUrl'] ?? '');
$this->cfp = new EventCfp(
(string) ($data['cfp']['googleFormId'] ?? ''),
new DateTimeRange(
new DateTimeImmutable($data['cfp']['startDate'] ?? ''),
new DateTimeImmutable($data['cfp']['endDate'] ?? ''),
),
);
$this->sponsors = new EventSponsors($data);
$this->speakers = new EventSpeakers($data, $this->objectManager);
$this->schedule = new EventSchedule($data, $this->speakers);
if ($data['schedule'] !== []) {
$firstSlot = current($data['schedule']);
$lastSlot = end($data['schedule']);
$this->dateTimeRange = new DateTimeRange(
new DateTimeImmutable($firstSlot['startDate'] ?? ''),
new DateTimeImmutable($lastSlot['endDate'] ?? ''),
);
} else {
$this->dateTimeRange = new DateTimeRange(
new DateTimeImmutable($data['startDate'] ?? ''),
new DateTimeImmutable($data['endDate'] ?? ''),
);
}
$this->registrationDateTimeRange = new DateTimeRange(
isset($data['registrationStartDate'])
? new DateTimeImmutable($data['registrationStartDate'])
: $this->dateTimeRange->getStart(),
isset($data['registrationEndDate'])
? new DateTimeImmutable($data['registrationEndDate'])
: $this->dateTimeRange->getEnd(),
);
$this->description = (string) ($data['description'] ?? '');
$this->price = (float) ($data['price'] ?? 0.00);
}
}

View File

@@ -1,142 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use DateTimeImmutable;
use Doctrine\SkeletonMapper\Mapping\ClassMetadataInterface;
use Doctrine\SkeletonMapper\Mapping\LoadMetadataInterface;
final class Event implements LoadMetadataInterface
{
private int $id;
private string $type;
private string $sku;
private string $name;
private string $slug;
private string $joinUrl;
private DateTimeRange $dateTimeRange;
private DateTimeRange $registrationDateTimeRange;
private EventCfp $cfp;
private EventLocation|null $location = null;
private EventSponsors $sponsors;
private EventSpeakers $speakers;
private EventSchedule $schedule;
private string $description;
private float $price;
public static function loadMetadata(ClassMetadataInterface $metadata): void
{
$metadata->setIdentifier(['id']);
}
public function getId(): int
{
return $this->id;
}
public function isWebinar(): bool
{
return $this->type === EventType::WEBINAR;
}
public function isConference(): bool
{
return $this->type === EventType::CONFERENCE;
}
public function getSku(): string
{
return $this->sku;
}
public function getName(): string
{
return $this->name;
}
public function getSlug(): string
{
return $this->slug;
}
public function getJoinUrl(): string
{
return $this->joinUrl;
}
public function getDates(): DateTimeRange
{
return $this->dateTimeRange;
}
public function getRegistrationDates(): DateTimeRange
{
return $this->registrationDateTimeRange;
}
public function getStartDate(): DateTimeImmutable
{
return $this->dateTimeRange->getStart();
}
public function getEndDate(): DateTimeImmutable
{
return $this->dateTimeRange->getEnd();
}
public function getCfp(): EventCfp
{
return $this->cfp;
}
public function getLocation(): EventLocation|null
{
return $this->location;
}
public function getSponsors(): EventSponsors
{
return $this->sponsors;
}
public function getSpeakers(): EventSpeakers
{
return $this->speakers;
}
public function getSchedule(): EventSchedule
{
return $this->schedule;
}
public function getDescription(): string
{
return $this->description;
}
public function getPrice(): float
{
return $this->price;
}
public function isFree(): bool
{
return $this->price === 0.00;
}
}

View File

@@ -1,40 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use LogicException;
use function sprintf;
final class EventCfp
{
public function __construct(private string $googleFormId, private DateTimeRange $dateTimeRange)
{
}
public function exists(): bool
{
return $this->googleFormId !== '';
}
public function getGoogleFormUrl(): string
{
if (! $this->exists()) {
throw new LogicException('Cannot call EventCfp::getGoogleFormUrl() when no googleFormId is set.');
}
return sprintf('https://docs.google.com/forms/d/e/%s/viewform', $this->googleFormId);
}
public function getEmbeddedGoogleFormUrl(): string
{
return sprintf('%s?embedded=true', $this->getGoogleFormUrl());
}
public function getDates(): DateTimeRange
{
return $this->dateTimeRange;
}
}

View File

@@ -1,22 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
final class EventLocation
{
public function __construct(private string $name, private Address $address)
{
}
public function getName(): string
{
return $this->name;
}
public function getAddress(): Address
{
return $this->address;
}
}

View File

@@ -1,45 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use DateTimeImmutable;
use Doctrine\Common\Collections\AbstractLazyCollection;
use Doctrine\Common\Collections\ArrayCollection;
use InvalidArgumentException;
use function sprintf;
/** @template-extends AbstractLazyCollection<int, EventScheduleSlot> */
final class EventSchedule extends AbstractLazyCollection
{
/** @param mixed[] $event */
public function __construct(private array $event, private EventSpeakers $speakers)
{
}
protected function doInitialize(): void
{
$slots = [];
foreach ($this->event['schedule'] as $slot) {
if (! isset($this->speakers[$slot['topicSlug']])) {
throw new InvalidArgumentException(sprintf(
'Could not find speaker with topicSlug "%s".',
$slot['topicSlug'],
));
}
$eventSpeaker = $this->speakers[$slot['topicSlug']];
$slots[] = new EventScheduleSlot(
$eventSpeaker,
new DateTimeImmutable($slot['startDate'] ?? ''),
new DateTimeImmutable($slot['endDate'] ?? ''),
);
}
$this->collection = new ArrayCollection($slots);
}
}

View File

@@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use DateTimeImmutable;
final class EventScheduleSlot
{
public function __construct(
private EventSpeaker $speaker,
private DateTimeImmutable $startDate,
private DateTimeImmutable $endDate,
) {
}
public function getSpeaker(): EventSpeaker
{
return $this->speaker;
}
public function getStartDate(): DateTimeImmutable
{
return $this->startDate;
}
public function getEndDate(): DateTimeImmutable
{
return $this->endDate;
}
}

View File

@@ -1,60 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use function sprintf;
final class EventSpeaker
{
public function __construct(
private string $name,
private string $avatarUrl,
private string $topic,
private string $topicSlug,
private string $description,
private string $youTubeVideoId,
) {
}
public function getName(): string
{
return $this->name;
}
public function getAvatarUrl(): string
{
return $this->avatarUrl;
}
public function getTopic(): string
{
return $this->topic;
}
public function getTopicSlug(): string
{
return $this->topicSlug;
}
public function getDescription(): string
{
return $this->description;
}
public function hasYouTubeVideo(): bool
{
return $this->youTubeVideoId !== '';
}
public function getYouTubeVideoId(): string
{
return $this->youTubeVideoId;
}
public function getYouTubeUrl(): string
{
return sprintf('https://www.youtube.com/watch?v=%s', $this->youTubeVideoId);
}
}

View File

@@ -1,50 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use Doctrine\Common\Collections\AbstractLazyCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\SkeletonMapper\ObjectManagerInterface;
use Doctrine\Website\Repositories\TeamMemberRepository;
use function assert;
/** @template-extends AbstractLazyCollection<string, EventSpeaker> */
final class EventSpeakers extends AbstractLazyCollection
{
/** @param mixed[] $event */
public function __construct(private array $event, private ObjectManagerInterface $objectManager)
{
}
protected function doInitialize(): void
{
$teamMemberRepository = $this->objectManager->getRepository(TeamMember::class);
assert($teamMemberRepository instanceof TeamMemberRepository);
$speakers = [];
foreach ($this->event['speakers'] ?? [] as $speaker) {
$speakerName = (string) ($speaker['name'] ?? '');
$teamMember = $speakerName !== ''
? $teamMemberRepository->findOneByGithub($speakerName)
: null;
$topicSlug = (string) ($speaker['topicSlug'] ?? '');
$speakers[$topicSlug] = new EventSpeaker(
$teamMember?->getName() ?? $speakerName,
$teamMember?->getAvatarUrl() ?? (string) ($speaker['avatarUrl'] ?? ''),
(string) ($speaker['topic'] ?? ''),
$topicSlug,
(string) ($speaker['description'] ?? ''),
(string) ($speaker['youTubeVideoId'] ?? ''),
);
}
$this->collection = new ArrayCollection($speakers);
}
}

View File

@@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
final class EventSponsor
{
public function __construct(private string $name, private string $url, private string $logo, private UtmParameters $utmParameters)
{
}
public function getName(): string
{
return $this->name;
}
public function getUrl(): string
{
return $this->url;
}
/** @param string[] $parameters */
public function getUrlWithUtmParameters(array $parameters = []): string
{
return $this->utmParameters->buildUrl($this->url, $parameters);
}
public function getLogo(): string
{
return $this->logo;
}
}

View File

@@ -1,44 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
use Doctrine\Common\Collections\AbstractLazyCollection;
use Doctrine\Common\Collections\ArrayCollection;
use function array_merge;
/** @template-extends AbstractLazyCollection<int, EventSponsor> */
final class EventSponsors extends AbstractLazyCollection
{
/** @param mixed[] $event */
public function __construct(private array $event)
{
}
protected function doInitialize(): void
{
$sponsors = [];
foreach ($this->event['sponsors'] ?? [] as $sponsor) {
$sponsors[] = new EventSponsor(
(string) ($sponsor['name'] ?? ''),
(string) ($sponsor['url'] ?? ''),
(string) ($sponsor['logo'] ?? ''),
new UtmParameters(
array_merge(
[
'utm_source' => 'doctrine',
'utm_medium' => 'website',
'utm_campaign' => $this->event['slug'],
],
$sponsor['utmParameters'] ?? [],
),
),
);
}
$this->collection = new ArrayCollection($sponsors);
}
}

View File

@@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Model;
final class EventType
{
public const WEBINAR = 'webinar';
public const CONFERENCE = 'conference';
private function __construct()
{
}
}

View File

@@ -1,56 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Repositories;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\SkeletonMapper\ObjectRepository\BasicObjectRepository;
use Doctrine\Website\Model\Event;
use InvalidArgumentException;
use function sprintf;
/**
* @template T of Event
* @template-extends BasicObjectRepository<T>
*/
class EventRepository extends BasicObjectRepository
{
public function findOneById(int $id): Event
{
$event = $this->findOneBy(['id' => $id]);
if ($event === null) {
throw new InvalidArgumentException(sprintf('Could not find Event with id "%s"', $id));
}
return $event;
}
/** @return Event[] */
public function findUpcomingEvents(): array
{
/** @var Event[] $events */
$events = $this->findBy([], ['startDate' => 'asc']);
$criteria = Criteria::create()
->where(Criteria::expr()->gt('startDate', new DateTimeImmutable()));
return (new ArrayCollection($events))->matching($criteria)->toArray();
}
/** @return Event[] */
public function findPastEvents(): array
{
/** @var Event[] $events */
$events = $this->findBy([], ['endDate' => 'desc']);
$criteria = Criteria::create()
->where(Criteria::expr()->lt('endDate', new DateTimeImmutable()));
return (new ArrayCollection($events))->matching($criteria)->toArray();
}
}

View File

@@ -1,35 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Requests;
use Doctrine\StaticWebsiteGenerator\Request\ArrayRequestCollection;
use Doctrine\StaticWebsiteGenerator\Request\RequestCollection;
use Doctrine\Website\Model\Event;
use Doctrine\Website\Repositories\EventRepository;
class EventRequests
{
/** @param EventRepository<Event> $eventRepository */
public function __construct(private EventRepository $eventRepository)
{
}
public function getEvents(): RequestCollection
{
/** @var Event[] $events */
$events = $this->eventRepository->findAll();
$requests = [];
foreach ($events as $event) {
$requests[] = [
'id' => $event->getId(),
'slug' => $event->getSlug(),
];
}
return new ArrayRequestCollection($requests);
}
}

View File

@@ -22,6 +22,3 @@ parameters:
- # Temporary final classes in tests are covered by nunomaduro/mock-final-classes until the refactorings start
message: "#contains unresolvable type#"
path: "tests/"
-
message: "#does not specify its types: TStripeObject#"
path: "lib/Event/GetStripeEventParticipants.php"

View File

@@ -1,273 +0,0 @@
<?php
declare(strict_types=1);
namespace Doctrine\Website\Tests\Model;
use DateTimeImmutable;
use Doctrine\Website\Model\Event;
use Doctrine\Website\Model\EventScheduleSlot;
use Doctrine\Website\Model\EventSpeaker;
use Doctrine\Website\Model\EventSponsor;
use Doctrine\Website\Model\EventType;
use Doctrine\Website\Tests\TestCase;
use function array_merge;
final class EventTest extends TestCase
{
public function testIsWebinar(): void
{
self::assertTrue($this->createTestEvent()->isWebinar());
self::assertFalse($this->createTestEvent([
'type' => EventType::CONFERENCE,
'location' => [],
])->isWebinar());
}
public function testIsConference(): void
{
self::assertFalse($this->createTestEvent()->isConference());
self::assertTrue($this->createTestEvent([
'type' => EventType::CONFERENCE,
'location' => [],
])->isConference());
}
public function testGetSku(): void
{
self::assertSame('test_123', $this->createTestEvent()->getSku());
}
public function testGetName(): void
{
self::assertSame('Doctrine for Beginners', $this->createTestEvent()->getName());
}
public function testGetSlug(): void
{
self::assertSame('doctrine-for-beginners', $this->createTestEvent()->getSlug());
}
public function testGetJoinUrl(): void
{
self::assertSame('https://www.joinurl.com', $this->createTestEvent()->getJoinUrl());
}
public function testGetDates(): void
{
self::assertEquals(
new DateTimeImmutable('2019-05-28 11:00:00'),
$this->createTestEvent()->getDates()->getStart(),
);
self::assertEquals(
new DateTimeImmutable('2019-05-28 11:00:00'),
$this->createTestEvent()->getStartDate(),
);
self::assertEquals(
new DateTimeImmutable('2019-05-28 11:45:00'),
$this->createTestEvent()->getDates()->getEnd(),
);
self::assertEquals(
new DateTimeImmutable('2019-05-28 11:45:00'),
$this->createTestEvent()->getEndDate(),
);
self::assertSame(0, $this->createTestEvent()->getDates()->getNumDays());
self::assertSame(0, $this->createTestEvent()->getDates()->getNumHours());
self::assertSame(45, $this->createTestEvent()->getDates()->getNumMinutes());
self::assertSame('45-minute', $this->createTestEvent()->getDates()->getDuration());
self::assertSame(3, $this->createTestEvent([
'schedule' => [],
'startDate' => '2019-05-28',
'endDate' => '2019-05-30',
])->getDates()->getNumDays());
self::assertSame('3-day', $this->createTestEvent([
'schedule' => [],
'startDate' => '2019-05-28',
'endDate' => '2019-05-30',
])->getDates()->getDuration());
self::assertSame(71, $this->createTestEvent([
'schedule' => [],
'startDate' => '2019-05-28 11:00:00',
'endDate' => '2019-05-30 10:00:00',
])->getDates()->getNumHours());
}
public function testGetRegistrationDates(): void
{
self::assertEquals(
new DateTimeImmutable('2019-05-01'),
$this->createTestEvent()->getRegistrationDates()->getStart(),
);
self::assertEquals(
new DateTimeImmutable('2019-05-27'),
$this->createTestEvent()->getRegistrationDates()->getEnd(),
);
}
public function testGetCfp(): void
{
self::assertTrue($this->createTestEvent()->getCfp()->exists());
self::assertSame(
'https://docs.google.com/forms/d/e/123/viewform',
$this->createTestEvent()->getCfp()->getGoogleFormUrl(),
);
self::assertSame(
'https://docs.google.com/forms/d/e/123/viewform?embedded=true',
$this->createTestEvent()->getCfp()->getEmbeddedGoogleFormUrl(),
);
self::assertEquals(
new DateTimeImmutable('2019-05-01'),
$this->createTestEvent()->getCfp()->getDates()->getStart(),
);
self::assertEquals(
new DateTimeImmutable('2019-05-02'),
$this->createTestEvent()->getCfp()->getDates()->getEnd(),
);
}
public function testGetLocation(): void
{
self::assertNull($this->createTestEvent()->getLocation());
$event = $this->createTestEvent([
'type' => EventType::CONFERENCE,
'location' => [
'name' => 'Awesome Hotel',
'address' => [
'line1' => 'Line 1',
'line2' => 'Line 2',
'city' => 'City',
'state' => 'State',
'zipCode' => 'Zip Code',
'countryCode' => 'Country Code',
],
],
]);
$location = $event->getLocation();
self::assertNotNull($location);
self::assertSame('Awesome Hotel', $location->getName());
self::assertSame('Line 1', $location->getAddress()->getLine1());
self::assertSame('Line 2', $location->getAddress()->getLine2());
self::assertSame('City', $location->getAddress()->getCity());
self::assertSame('State', $location->getAddress()->getState());
self::assertSame('Zip Code', $location->getAddress()->getZipCode());
self::assertSame('Country Code', $location->getAddress()->getCountryCode());
}
public function testGetSponsors(): void
{
$sponsor = $this->createTestEvent()->getSponsors()->first();
self::assertInstanceOf(EventSponsor::class, $sponsor);
self::assertSame('Blackfire.io', $sponsor->getName());
self::assertSame('https://blackfire.io/', $sponsor->getUrl());
self::assertSame(
'https://blackfire.io/?utm_source=doctrine&utm_medium=website&utm_campaign=doctrine-for-beginners',
$sponsor->getUrlWithUtmParameters(),
);
self::assertSame('/images/blackfire.svg', $sponsor->getLogo());
}
public function testGetSpeakers(): void
{
$speaker = $this->createTestEvent()->getSpeakers()->first();
self::assertInstanceOf(EventSpeaker::class, $speaker);
self::assertSame('Jonathan H. Wage', $speaker->getName());
self::assertSame('Doctrine for Beginners', $speaker->getTopic());
self::assertSame('doctrine-for-beginners', $speaker->getTopicSlug());
self::assertSame('Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost a billion times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.', $speaker->getDescription());
}
public function testGetSchedule(): void
{
$event = $this->createTestEvent();
$speaker = $event->getSpeakers()->first();
$slot = $event->getSchedule()->first();
self::assertInstanceOf(EventScheduleSlot::class, $slot);
self::assertSame($speaker, $slot->getSpeaker());
}
public function testGetDescription(): void
{
self::assertSame('Test Description', $this->createTestEvent()->getDescription());
}
public function testGetPrice(): void
{
self::assertSame(0.00, $this->createTestEvent()->getPrice());
self::assertSame(5.00, $this->createTestEvent(['price' => 5.00])->getPrice());
}
public function testIsFree(): void
{
self::assertTrue($this->createTestEvent()->isFree());
self::assertFalse($this->createTestEvent(['price' => 5.00])->isFree());
}
/** @param mixed[] $data */
private function createTestEvent(array $data = []): Event
{
return $this->createEvent(array_merge([
'env' => 'dev',
'sku' => [
'test' => 'test_123',
'prod' => 'prod_123',
],
'cfp' => [
'googleFormId' => '123',
'startDate' => '2019-05-01',
'endDate' => '2019-05-02',
],
'name' => 'Doctrine for Beginners',
'slug' => 'doctrine-for-beginners',
'description' => 'Test Description',
'price' => 0.0,
'joinUrl' => 'https://www.joinurl.com',
'startDate' => '2019-05-28',
'endDate' => '2019-05-28',
'registrationStartDate' => '2019-05-01',
'registrationEndDate' => '2019-05-27',
'sponsors' => [
[
'name' => 'Blackfire.io',
'url' => 'https://blackfire.io/',
'logo' => '/images/blackfire.svg',
'utmParameters' => ['utm_source' => 'doctrine'],
],
],
'speakers' => [
[
'name' => 'jwage',
'topic' => 'Doctrine for Beginners',
'topicSlug' => 'doctrine-for-beginners',
'description' => 'Come to this talk prepared to learn about the Doctrine PHP open source project. The Doctrine project has been around for over a decade and has evolved from database abstraction software that dates back to the PEAR days. The packages provided by the Doctrine project have been downloaded almost a billion times from packagist. In this talk we will take you through how to get started with Doctrine and how to take advantage of some of the more advanced features.',
],
],
'schedule' => [
[
'topicSlug' => 'doctrine-for-beginners',
'startDate' => '2019-05-28 11:00',
'endDate' => '2019-05-28 11:45',
],
],
], $data));
}
}

View File

@@ -7,18 +7,14 @@ namespace Doctrine\Website\Tests;
use Doctrine\SkeletonMapper\ObjectRepository\ObjectRepositoryInterface;
use Doctrine\Website\Application;
use Doctrine\Website\Model\Contributor;
use Doctrine\Website\Model\Event;
use Doctrine\Website\Model\Project;
use Doctrine\Website\Model\ProjectContributor;
use Doctrine\Website\Repositories\ContributorRepository;
use Doctrine\Website\Repositories\EventRepository;
use Doctrine\Website\Repositories\ProjectContributorRepository;
use Doctrine\Website\Repositories\ProjectRepository;
use PHPUnit\Framework\TestCase as BaseTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function mt_rand;
abstract class TestCase extends BaseTestCase
{
private static ContainerBuilder|null $container = null;
@@ -45,17 +41,6 @@ abstract class TestCase extends BaseTestCase
return $object;
}
/** @param mixed[] $data */
protected function createEvent(array $data): Event
{
$data['id'] = mt_rand();
$event = $this->createModel(EventRepository::class, $data);
self::assertInstanceOf(Event::class, $event);
return $event;
}
/** @param mixed[] $data */
protected function createProject(array $data): Project
{