diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 3339563e2..80a9a3dd0 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -4189,24 +4189,12 @@ 'count' => 2, 'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getIterator\\(\\) on CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php', -]; $ignoreErrors[] = [ 'message' => '#^Method AppBundle\\\\Controller\\\\Api\\\\Antennes\\\\GetOneAction\\:\\:transformMeetup\\(\\) return type has no value type specified in iterable type array\\.$#', 'identifier' => 'missingType.iterableValue', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(AppBundle\\\\Event\\\\Model\\\\Meetup\\)\\: array given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot access offset \'email\' on mixed\\.$#', 'identifier' => 'offsetAccess.nonOffsetAccessible', @@ -4802,7 +4790,7 @@ 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Global/HomeAction.php', ]; $ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Controller\\\\Website\\\\Global\\\\HomeAction\\:\\:getLatestMeetups\\(\\) should return array\\ but returns mixed\\.$#', + 'message' => '#^Method AppBundle\\\\Controller\\\\Website\\\\Global\\\\HomeAction\\:\\:getLatestMeetups\\(\\) should return array\\ but returns mixed\\.$#', 'identifier' => 'return.type', 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Controller/Website/Global/HomeAction.php', @@ -6127,12 +6115,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Lead.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Meetup\\:\\:getLocation\\(\\) should return string but returns string\\|null\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Meetup.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot cast mixed to int\\.$#', 'identifier' => 'cast.int', @@ -6565,36 +6547,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/InvoiceRepository.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:findAllForAntenne\\(\\) return type with generic interface CCMBenchmark\\\\Ting\\\\Repository\\\\CollectionInterface does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:findNextForAntenne\\(\\) should return AppBundle\\\\Event\\\\Model\\\\Meetup\\|null but returns mixed\\.$#', - 'identifier' => 'return.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:initMetadata\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', - 'identifier' => 'missingType.iterableValue', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\MeetupRepository\\:\\:initMetadata\\(\\) return type with generic class CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata does not specify its types\\: T$#', - 'identifier' => 'missingType.generics', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$databaseName of method CCMBenchmark\\\\Ting\\\\Repository\\\\Metadata\\\\:\\:setDatabase\\(\\) expects string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Event/Model/Repository/MeetupRepository.php', -]; $ignoreErrors[] = [ 'message' => '#^Method AppBundle\\\\Event\\\\Model\\\\Repository\\\\PlanningRepository\\:\\:getByTalk\\(\\) should return AppBundle\\\\Event\\\\Model\\\\Planning\\|null but returns mixed\\.$#', 'identifier' => 'return.type', diff --git a/sources/AppBundle/Command/IndexMeetupsCommand.php b/sources/AppBundle/Command/IndexMeetupsCommand.php index fed784ead..11572bfa0 100644 --- a/sources/AppBundle/Command/IndexMeetupsCommand.php +++ b/sources/AppBundle/Command/IndexMeetupsCommand.php @@ -7,7 +7,7 @@ use Algolia\AlgoliaSearch\Exceptions\AlgoliaException; use Algolia\AlgoliaSearch\SearchClient; use AppBundle\Antennes\AntenneRepository; -use AppBundle\Event\Model\Repository\MeetupRepository; +use AppBundle\Event\Entity\Repository\MeetupRepository; use AppBundle\Indexation\Meetups\Runner; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; diff --git a/sources/AppBundle/Command/ScrappingMeetupEventsCommand.php b/sources/AppBundle/Command/ScrappingMeetupEventsCommand.php index 09d0335a1..3c52f8789 100644 --- a/sources/AppBundle/Command/ScrappingMeetupEventsCommand.php +++ b/sources/AppBundle/Command/ScrappingMeetupEventsCommand.php @@ -4,7 +4,7 @@ namespace AppBundle\Command; -use AppBundle\Event\Model\Repository\MeetupRepository; +use AppBundle\Event\Entity\Repository\MeetupRepository; use AppBundle\Indexation\Meetups\MeetupClient; use CuyZ\Valinor\Mapper\MappingError; use Symfony\Component\Console\Command\Command; @@ -56,16 +56,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($meetups as $meetup) { $io->progressAdvance(); - $id = $meetup->getId(); - $existingMeetup = $this->meetupRepository->get($id); + $existingMeetup = null; + if (isset($meetup->id)) { + $existingMeetup = $this->meetupRepository->find($meetup->id); + } // Si le meetup est déjà présent en base, il est mis à jour. if ($existingMeetup) { - $existingMeetup->setTitle($meetup->getTitle()); - $existingMeetup->setDescription($meetup->getDescription()); - $existingMeetup->setLocation($meetup->getLocation()); - $existingMeetup->setDate($meetup->getDate()); - $existingMeetup->setPhotoUrl($meetup->getPhotoUrl()); + $existingMeetup->titre = $meetup->titre; + $existingMeetup->description = $meetup->description; + $existingMeetup->lieu = $meetup->lieu; + $existingMeetup->date = $meetup->date; + $existingMeetup->photoUrl = $meetup->photoUrl; // On doit remplacer la variable, car l'ORM a une référence vers l'instance récupérée // via le get et pas celle de la boucle. diff --git a/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php b/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php index cf5ed4707..c084c91c5 100644 --- a/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php +++ b/sources/AppBundle/Controller/Api/Antennes/GetOneAction.php @@ -6,8 +6,8 @@ use AppBundle\Antennes\Antenne; use AppBundle\Antennes\AntenneRepository; -use AppBundle\Event\Model\Meetup; -use AppBundle\Event\Model\Repository\MeetupRepository; +use AppBundle\Event\Entity\Meetup; +use AppBundle\Event\Entity\Repository\MeetupRepository; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -55,7 +55,7 @@ public function __invoke(string $code): JsonResponse $response['meetups'] = array_map( fn(Meetup $meetup): array => $this->transformMeetup($antenne, $meetup), - iterator_to_array($allMeetups->getIterator()), + $allMeetups, ); return new JsonResponse($response); @@ -73,12 +73,12 @@ private function createLink(string $prefix, ?string $suffix): ?string private function transformMeetup(Antenne $antenne, Meetup $meetup): array { return [ - 'title' => $meetup->getTitle(), - 'date' => $meetup->getDate()->format('Y-m-d H:i:s'), - 'location' => $meetup->getLocation(), - 'description' => $meetup->getDescription(), - 'url' => 'https://www.meetup.com/fr-FR/' . $antenne->meetup->urlName . '/events/' . $meetup->getId(), - 'photo' => $meetup->getPhotoUrl(), + 'title' => $meetup->titre, + 'date' => $meetup->date->format('Y-m-d H:i:s'), + 'location' => $meetup->lieu, + 'description' => $meetup->description, + 'url' => 'https://www.meetup.com/fr-FR/' . $antenne->meetup->urlName . '/events/' . $meetup->id, + 'photo' => $meetup->photoUrl, ]; } } diff --git a/sources/AppBundle/Controller/Website/Global/HomeAction.php b/sources/AppBundle/Controller/Website/Global/HomeAction.php index a8d2d05b8..29443bb00 100644 --- a/sources/AppBundle/Controller/Website/Global/HomeAction.php +++ b/sources/AppBundle/Controller/Website/Global/HomeAction.php @@ -7,7 +7,7 @@ use Afup\Site\Corporate\Feuille; use Algolia\AlgoliaSearch\Exceptions\AlgoliaException; use Algolia\AlgoliaSearch\SearchClient; -use AppBundle\Event\Model\Meetup; +use AppBundle\Event\Entity\Meetup; use AppBundle\Event\Model\Repository\TalkRepository; use AppBundle\Event\Model\Talk; use AppBundle\Site\Entity\Repository\ArticleRepository; @@ -69,7 +69,7 @@ protected function getLatestMeetups(): array return []; } - $cacheKey = 'home_algolia_meetups'; + $cacheKey = 'home_algolia_meetups_doctrine'; try { $cacheItem = $this->cache->getItem($cacheKey); diff --git a/sources/AppBundle/Event/Entity/Meetup.php b/sources/AppBundle/Event/Entity/Meetup.php new file mode 100644 index 000000000..3a302b57b --- /dev/null +++ b/sources/AppBundle/Event/Entity/Meetup.php @@ -0,0 +1,34 @@ + + */ +final class MeetupRepository extends EntityRepository +{ + use ClockAwareTrait; + + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Meetup::class); + } + + public function findNextForAntenne(Antenne $antenne): ?Meetup + { + /** @var Meetup|null $meetup */ + $meetup = ($qb = $this->createQueryBuilder('m')) + ->where($qb->expr()->eq('m.codeAntenne', ':codeAntenne')) + ->setParameter('codeAntenne', $antenne->code) + ->andWhere($qb->expr()->gt('m.date', ':after')) + ->setParameter('after', $this->now()->modify('midnight')) + ->orderBy('m.date', 'DESC') + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult(); + + return $meetup; + } + + /** + * @return array + */ + public function findAllForAntenne(Antenne $antenne): array + { + return ($qb = $this->createQueryBuilder('m')) + ->where($qb->expr()->eq('m.codeAntenne', ':codeAntenne')) + ->setParameter('codeAntenne', $antenne->code) + ->getQuery() + ->getResult(); + } +} diff --git a/sources/AppBundle/Event/Model/Meetup.php b/sources/AppBundle/Event/Model/Meetup.php deleted file mode 100644 index b39bb35d1..000000000 --- a/sources/AppBundle/Event/Model/Meetup.php +++ /dev/null @@ -1,171 +0,0 @@ -id; - } - - /** - * @param int $id - */ - public function setId($id): self - { - $this->propertyChanged('id', $this->id, $id); - $this->id = $id; - - return $this; - } - - /** - * @return DateTime - */ - public function getDate() - { - return $this->date; - } - - /** - * @param DateTime $date - */ - public function setDate($date): self - { - $this->propertyChanged('date', $this->date, $date); - $this->date = $date; - - return $this; - } - - /** - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * @param string $title - */ - public function setTitle($title): self - { - $this->propertyChanged('title', $this->title, $title); - $this->title = $title; - - return $this; - } - - /** - * @return string - */ - public function getLocation() - { - return $this->location; - } - - /** - * @param string|null $location - */ - public function setLocation($location = null): self - { - $this->propertyChanged('location', $this->location, $location); - $this->location = $location; - - return $this; - } - - /** - * @return ?string - */ - public function getDescription() - { - return $this->description; - } - - /** - * @param ?string $description - */ - public function setDescription($description): self - { - $this->propertyChanged('description', $this->description, $description); - $this->description = $description; - - return $this; - } - - /** - * @return string - */ - public function getAntenneName() - { - return $this->antenneName; - } - - /** - * @param string $antenneName - */ - public function setAntenneName($antenneName): self - { - $this->propertyChanged('antenneName', $this->antenneName, $antenneName); - $this->antenneName = $antenneName; - - return $this; - } - - public function getPhotoUrl(): ?string - { - return $this->photoUrl; - } - - public function setPhotoUrl(?string $photoUrl): void - { - $this->propertyChanged('photoUrl', $this->photoUrl, $photoUrl); - $this->photoUrl = $photoUrl; - } -} diff --git a/sources/AppBundle/Event/Model/Repository/MeetupRepository.php b/sources/AppBundle/Event/Model/Repository/MeetupRepository.php deleted file mode 100644 index d911bce00..000000000 --- a/sources/AppBundle/Event/Model/Repository/MeetupRepository.php +++ /dev/null @@ -1,119 +0,0 @@ - - */ -class MeetupRepository extends Repository implements MetadataInitializer -{ - use ClockAwareTrait; - - public function findNextForAntenne(Antenne $antenne): ?Meetup - { - /** @var SelectInterface $qb */ - $qb = $this->getQueryBuilder(self::QUERY_SELECT); - $qb - ->from('afup_meetup m') - ->cols(['m.*']) - ->where('m.antenne_name = :name') - ->where('m.date > :after') - ->orderBy(['m.date desc']) - ->limit(1) - ; - - return $this->getPreparedQuery($qb->getStatement()) - ->setParams([ - 'name' => $antenne->code, - 'after' => $this->now()->modify('midnight')->format(DATE_RFC3339), - ]) - ->query($this->getCollection(new HydratorSingleObject())) - ->first(); - } - - public function findAllForAntenne(Antenne $antenne): ?CollectionInterface - { - /** @var SelectInterface $qb */ - $qb = $this->getQueryBuilder(self::QUERY_SELECT); - $qb - ->from('afup_meetup m') - ->cols(['m.*']) - ->where('m.antenne_name = :name') - ; - - return $this->getPreparedQuery($qb->getStatement()) - ->setParams([ - 'name' => $antenne->code, - ]) - ->query($this->getCollection(new HydratorSingleObject())); - } - - /** - * - * @return Metadata - */ - public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) - { - $metadata = new Metadata($serializerFactory); - - $metadata->setEntity(Meetup::class); - $metadata->setConnectionName('main'); - $metadata->setDatabase($options['database']); - $metadata->setTable('afup_meetup'); - - $metadata - ->addField([ - 'columnName' => 'id', - 'fieldName' => 'id', - 'primary' => true, - 'autoincrement' => false, - 'type' => 'int', - ]) - ->addField([ - 'columnName' => 'date', - 'fieldName' => 'date', - 'type' => 'datetime', - ]) - ->addField([ - 'columnName' => 'title', - 'fieldName' => 'title', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'location', - 'fieldName' => 'location', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'description', - 'fieldName' => 'description', - 'type' => 'text', - 'nullable' => true, - ]) - ->addField([ - 'columnName' => 'antenne_name', - 'fieldName' => 'antenneName', - 'type' => 'string', - ]) - ->addField([ - 'columnName' => 'photo_url', - 'fieldName' => 'photoUrl', - 'type' => 'string', - ]); - - return $metadata; - } -} diff --git a/sources/AppBundle/Indexation/Meetups/GraphQL/Node.php b/sources/AppBundle/Indexation/Meetups/GraphQL/Node.php index d6297fa78..c5d502f7a 100644 --- a/sources/AppBundle/Indexation/Meetups/GraphQL/Node.php +++ b/sources/AppBundle/Indexation/Meetups/GraphQL/Node.php @@ -4,7 +4,7 @@ namespace AppBundle\Indexation\Meetups\GraphQL; -use DateTime; +use DateTimeImmutable; final readonly class Node { @@ -12,7 +12,7 @@ public function __construct( public string $id, public string $title, public string $description, - public DateTime $dateTime, + public DateTimeImmutable $dateTime, public Venue $venue, public Photo $displayPhoto, ) {} diff --git a/sources/AppBundle/Indexation/Meetups/MeetupClient.php b/sources/AppBundle/Indexation/Meetups/MeetupClient.php index 3382f430f..4961874ac 100644 --- a/sources/AppBundle/Indexation/Meetups/MeetupClient.php +++ b/sources/AppBundle/Indexation/Meetups/MeetupClient.php @@ -5,7 +5,7 @@ namespace AppBundle\Indexation\Meetups; use AppBundle\Antennes\AntenneRepository; -use AppBundle\Event\Model\Meetup; +use AppBundle\Event\Entity\Meetup; use AppBundle\Indexation\Meetups\GraphQL\QueryGroupsResponse; use CuyZ\Valinor\Mapper\Source\Source; use CuyZ\Valinor\MapperBuilder; @@ -46,18 +46,18 @@ public function getEvents(?int $quantityOfPastEvents = null): array $meetups = []; - foreach ($groupResponse->data as $nameAntenne => $group) { + foreach ($groupResponse->data as $codeAntenne => $group) { $edges = array_merge($group->upcomingEvents->edges, $group->pastEvents->edges); foreach ($edges as $edge) { $meetup = new Meetup(); - $meetup->setId((int) $edge->node->id); - $meetup->setTitle($edge->node->title); - $meetup->setDescription($edge->node->description); - $meetup->setDate($edge->node->dateTime); - $meetup->setAntenneName($nameAntenne); - $meetup->setLocation($edge->node->venue->name); - $meetup->setPhotoUrl($edge->node->displayPhoto->standardUrl); + $meetup->id = (int) $edge->node->id; + $meetup->titre = $edge->node->title; + $meetup->description = $edge->node->description; + $meetup->date = $edge->node->dateTime; + $meetup->codeAntenne = $codeAntenne; + $meetup->lieu = $edge->node->venue->name; + $meetup->photoUrl = $edge->node->displayPhoto->standardUrl; $meetups[] = $meetup; } diff --git a/sources/AppBundle/Indexation/Meetups/Runner.php b/sources/AppBundle/Indexation/Meetups/Runner.php index e229f56c1..8b67d530f 100644 --- a/sources/AppBundle/Indexation/Meetups/Runner.php +++ b/sources/AppBundle/Indexation/Meetups/Runner.php @@ -7,9 +7,8 @@ use Algolia\AlgoliaSearch\SearchClient; use Algolia\AlgoliaSearch\SearchIndex; use AppBundle\Antennes\AntenneRepository; -use AppBundle\Event\Model\Meetup; -use AppBundle\Event\Model\Repository\MeetupRepository; -use CCMBenchmark\Ting\Repository\CollectionInterface; +use AppBundle\Event\Entity\Meetup; +use AppBundle\Event\Entity\Repository\MeetupRepository; final readonly class Runner { @@ -64,16 +63,16 @@ protected function initIndex(): SearchIndex private function getTransformedMeetupsFromDatabase(): array { - $meetupsCollection = $this->meetupRepository->getAll(); + $meetupsCollection = $this->meetupRepository->findAll(); return $this->transformMeetupsForIndexation($meetupsCollection); } /** - * @param CollectionInterface $meetupsCollection + * @param array $meetupsCollection * @return list */ - public function transformMeetupsForIndexation(CollectionInterface $meetupsCollection): array + public function transformMeetupsForIndexation(array $meetupsCollection): array { $meetupsArray = []; foreach ($meetupsCollection as $meetup) { diff --git a/sources/AppBundle/Indexation/Meetups/Transformer.php b/sources/AppBundle/Indexation/Meetups/Transformer.php index 942aebcf9..c76032cd8 100644 --- a/sources/AppBundle/Indexation/Meetups/Transformer.php +++ b/sources/AppBundle/Indexation/Meetups/Transformer.php @@ -6,7 +6,7 @@ use AppBundle\Antennes\Antenne; use AppBundle\Antennes\AntenneRepository; -use AppBundle\Event\Model\Meetup; +use AppBundle\Event\Entity\Meetup; class Transformer { @@ -19,9 +19,9 @@ public function __construct(private readonly AntenneRepository $antennesCollecti */ public function transform(Meetup $meetup): array { - $codeOffice = $meetup->getAntenneName(); + $codeOffice = $meetup->codeAntenne; $antenne = $this->antennesCollection->findByCode($codeOffice); - $datetime = $meetup->getDate(); + $datetime = $meetup->date; $isUpcoming = new \DateTime() < $datetime; @@ -30,8 +30,8 @@ public function transform(Meetup $meetup): array $parseDown = new \Parsedown(); $item = [ - 'meetup_id' => $meetup->getId(), - 'label' => $meetup->getTitle(), + 'meetup_id' => $meetup->id, + 'label' => $meetup->titre, 'event_url' => $eventUrl, 'timestamp' => $datetime->format('U'), 'year' => $datetime->format('Y'), @@ -41,9 +41,9 @@ public function transform(Meetup $meetup): array 'label' => $antenne->label, 'logo_url' => $antenne->logoUrl, ], - 'description' => $parseDown->parse($meetup->getDescription()), + 'description' => $parseDown->parse($meetup->description), 'is_upcoming' => $isUpcoming, - 'custom_sort' => $isUpcoming ? PHP_INT_MAX - $meetup->getDate()->getTimestamp() : $meetup->getDate()->getTimestamp(), + 'custom_sort' => $isUpcoming ? PHP_INT_MAX - $meetup->date->getTimestamp() : $meetup->date->getTimestamp(), ]; if ($antenne->socials->twitter !== null) { @@ -55,6 +55,6 @@ public function transform(Meetup $meetup): array private function getEventUrl(Antenne $antenne, Meetup $meetup): string { - return self::MEETUP_URL . $antenne->meetup->urlName . '/events/' . $meetup->getId(); + return self::MEETUP_URL . $antenne->meetup->urlName . '/events/' . $meetup->id; } } diff --git a/tests/unit/AppBundle/Indexation/Meetups/MeetupClientTest.php b/tests/unit/AppBundle/Indexation/Meetups/MeetupClientTest.php index 859478e57..cf946fdf6 100644 --- a/tests/unit/AppBundle/Indexation/Meetups/MeetupClientTest.php +++ b/tests/unit/AppBundle/Indexation/Meetups/MeetupClientTest.php @@ -125,37 +125,37 @@ public function testReturnsValidResponse(): void self::assertCount(4, $antennes); - self::assertEquals(12, $antennes[0]->getId()); - self::assertEquals('Upcoming 1', $antennes[0]->getTitle()); - self::assertEquals('Desc 1', $antennes[0]->getDescription()); - self::assertEquals(new \DateTime('2025-02-11T18:30:00+01:00'), $antennes[0]->getDate()); - self::assertEquals('lyon', $antennes[0]->getAntenneName()); - self::assertEquals('Lieu 1', $antennes[0]->getLocation()); - self::assertEquals('https://example.com/1', $antennes[0]->getPhotoUrl()); - - self::assertEquals(34, $antennes[1]->getId()); - self::assertEquals('Upcoming 2', $antennes[1]->getTitle()); - self::assertEquals('Desc 2', $antennes[1]->getDescription()); - self::assertEquals(new \DateTime('2025-03-20T18:30:00+01:00'), $antennes[1]->getDate()); - self::assertEquals('lyon', $antennes[1]->getAntenneName()); - self::assertNull($antennes[1]->getLocation()); - self::assertEquals('https://example.com/2', $antennes[1]->getPhotoUrl()); - - self::assertEquals(56, $antennes[2]->getId()); - self::assertEquals('Past 1', $antennes[2]->getTitle()); - self::assertEquals('Desc 3', $antennes[2]->getDescription()); - self::assertEquals(new \DateTime('2019-04-08T18:30:00+01:00'), $antennes[2]->getDate()); - self::assertEquals('lyon', $antennes[2]->getAntenneName()); - self::assertNull($antennes[2]->getLocation()); - self::assertEquals('https://example.com/3', $antennes[2]->getPhotoUrl()); - - self::assertEquals(78, $antennes[3]->getId()); - self::assertEquals('Past 2', $antennes[3]->getTitle()); - self::assertEquals('Desc 4', $antennes[3]->getDescription()); - self::assertEquals(new \DateTime('2020-10-17T18:30:00+01:00'), $antennes[3]->getDate()); - self::assertEquals('lyon', $antennes[3]->getAntenneName()); - self::assertEquals('Lieu 2', $antennes[3]->getLocation()); - self::assertEquals('https://example.com/4', $antennes[3]->getPhotoUrl()); + self::assertEquals(12, $antennes[0]->id); + self::assertEquals('Upcoming 1', $antennes[0]->titre); + self::assertEquals('Desc 1', $antennes[0]->description); + self::assertEquals(new \DateTime('2025-02-11T18:30:00+01:00'), $antennes[0]->date); + self::assertEquals('lyon', $antennes[0]->codeAntenne); + self::assertEquals('Lieu 1', $antennes[0]->lieu); + self::assertEquals('https://example.com/1', $antennes[0]->photoUrl); + + self::assertEquals(34, $antennes[1]->id); + self::assertEquals('Upcoming 2', $antennes[1]->titre); + self::assertEquals('Desc 2', $antennes[1]->description); + self::assertEquals(new \DateTime('2025-03-20T18:30:00+01:00'), $antennes[1]->date); + self::assertEquals('lyon', $antennes[1]->codeAntenne); + self::assertNull($antennes[1]->lieu); + self::assertEquals('https://example.com/2', $antennes[1]->photoUrl); + + self::assertEquals(56, $antennes[2]->id); + self::assertEquals('Past 1', $antennes[2]->titre); + self::assertEquals('Desc 3', $antennes[2]->description); + self::assertEquals(new \DateTime('2019-04-08T18:30:00+01:00'), $antennes[2]->date); + self::assertEquals('lyon', $antennes[2]->codeAntenne); + self::assertNull($antennes[2]->lieu); + self::assertEquals('https://example.com/3', $antennes[2]->photoUrl); + + self::assertEquals(78, $antennes[3]->id); + self::assertEquals('Past 2', $antennes[3]->titre); + self::assertEquals('Desc 4', $antennes[3]->description); + self::assertEquals(new \DateTime('2020-10-17T18:30:00+01:00'), $antennes[3]->date); + self::assertEquals('lyon', $antennes[3]->codeAntenne); + self::assertEquals('Lieu 2', $antennes[3]->lieu); + self::assertEquals('https://example.com/4', $antennes[3]->photoUrl); } private function makeGuzzleMockClient(ResponseInterface $response): HttpClientInterface diff --git a/tests/unit/AppBundle/Indexation/Meetups/TransformerTest.php b/tests/unit/AppBundle/Indexation/Meetups/TransformerTest.php index b0ea46ce2..c3998becb 100644 --- a/tests/unit/AppBundle/Indexation/Meetups/TransformerTest.php +++ b/tests/unit/AppBundle/Indexation/Meetups/TransformerTest.php @@ -5,7 +5,7 @@ namespace AppBundle\Tests\Indexation\Meetups; use AppBundle\Antennes\AntenneRepository; -use AppBundle\Event\Model\Meetup; +use AppBundle\Event\Entity\Meetup; use AppBundle\Indexation\Meetups\Transformer; use PHPUnit\Framework\TestCase; @@ -15,12 +15,12 @@ public function testTransform(): void { $transformer = new Transformer(new AntenneRepository()); - $meetup = new Meetup() - ->setId('244992881') - ->setDate(new \DateTime('2050-12-14 17:30:00')) - ->setTitle('Apéro PHP') - ->setDescription("Nous vous invitons au Grand Comptoir à partir de 18h30 pour discuter de PHP autour d'un verre.") - ->setAntenneName('reims'); + $meetup = new Meetup(); + $meetup->id = 244992881; + $meetup->date = new \DateTimeImmutable('2050-12-14 17:30:00'); + $meetup->titre = 'Apéro PHP'; + $meetup->description = "Nous vous invitons au Grand Comptoir à partir de 18h30 pour discuter de PHP autour d'un verre."; + $meetup->codeAntenne = 'reims'; $result = $transformer->transform($meetup);