From cc31cee9803813870e90280e47388e174aebb2ff Mon Sep 17 00:00:00 2001 From: Nico Oelgart Date: Wed, 10 Jun 2026 21:45:39 +0200 Subject: [PATCH] Fix gender category mapping --- ...leteGender.php => IFSCAthleteCategory.php} | 2 +- src/Domain/Round/IFSCRound.php | 4 +- .../Round/IFSCSameStreamRoundsMerger.php | 6 +-- .../StartList/IFSCStartListGenerator.php | 20 +++++----- src/Domain/StartList/IFSCStarter.php | 4 +- src/Domain/Tags/IFSCParsedTags.php | 14 +++---- src/Infrastructure/Calendar/ICalCalendar.php | 2 +- src/Infrastructure/Calendar/JsonCalendar.php | 6 +-- .../Round/IFSCSameStreamRoundsMergerTest.php | 40 +++++++++---------- .../StartList/IFSCStartListGeneratorTest.php | 24 +++++------ .../CalendarSpeedRelayFormattingTest.php | 4 +- 11 files changed, 63 insertions(+), 63 deletions(-) rename src/Domain/Athlete/{IFSCAthleteGender.php => IFSCAthleteCategory.php} (90%) diff --git a/src/Domain/Athlete/IFSCAthleteGender.php b/src/Domain/Athlete/IFSCAthleteCategory.php similarity index 90% rename from src/Domain/Athlete/IFSCAthleteGender.php rename to src/Domain/Athlete/IFSCAthleteCategory.php index 51cedec..210ff18 100644 --- a/src/Domain/Athlete/IFSCAthleteGender.php +++ b/src/Domain/Athlete/IFSCAthleteCategory.php @@ -7,7 +7,7 @@ */ namespace SportClimbing\IfscCalendar\Domain\Athlete; -enum IFSCAthleteGender: string +enum IFSCAthleteCategory: string { case MEN = 'men'; case WOMEN = 'women'; diff --git a/src/Domain/Round/IFSCRound.php b/src/Domain/Round/IFSCRound.php index 679acf4..16cc923 100644 --- a/src/Domain/Round/IFSCRound.php +++ b/src/Domain/Round/IFSCRound.php @@ -8,13 +8,13 @@ namespace SportClimbing\IfscCalendar\Domain\Round; use DateTimeImmutable; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDisciplines; use SportClimbing\IfscCalendar\Domain\Stream\LiveStream; final readonly class IFSCRound { - /** @param IFSCAthleteGender[] $categories */ + /** @param IFSCAthleteCategory[] $categories */ public function __construct( public string $name, public array $categories, diff --git a/src/Domain/Round/IFSCSameStreamRoundsMerger.php b/src/Domain/Round/IFSCSameStreamRoundsMerger.php index 734c249..a30783b 100644 --- a/src/Domain/Round/IFSCSameStreamRoundsMerger.php +++ b/src/Domain/Round/IFSCSameStreamRoundsMerger.php @@ -8,7 +8,7 @@ namespace SportClimbing\IfscCalendar\Domain\Round; use DateTimeImmutable; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\Tags\IFSCTagsParser; final readonly class IFSCSameStreamRoundsMerger @@ -108,7 +108,7 @@ private function buildMergedName(array $rounds): string /** * @param IFSCRound[] $rounds - * @return IFSCAthleteGender[] + * @return IFSCAthleteCategory[] */ private function mergedCategories(array $rounds): array { @@ -122,7 +122,7 @@ private function mergedCategories(array $rounds): array } } - usort($categories, static fn (IFSCAthleteGender $a, IFSCAthleteGender $b) => $a->value <=> $b->value); + usort($categories, static fn (IFSCAthleteCategory $a, IFSCAthleteCategory $b) => $a->value <=> $b->value); return $categories; } diff --git a/src/Domain/StartList/IFSCStartListGenerator.php b/src/Domain/StartList/IFSCStartListGenerator.php index dfd1f2d..00a7e02 100644 --- a/src/Domain/StartList/IFSCStartListGenerator.php +++ b/src/Domain/StartList/IFSCStartListGenerator.php @@ -13,7 +13,7 @@ use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteService; use SportClimbing\IfscCalendar\Domain\Ranking\IFSCAthleteRankingCalculator; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; final readonly class IFSCStartListGenerator { @@ -39,7 +39,7 @@ public function buildStartList(int $eventId): IFSCStartListResult $starter->score = $this->rankingCalculator->calculateScore($athlete); $starter->photoUrl = $athlete->photoUrl; $starter->instagram = $this->normalizeInstagram($athlete->instagram); - $starter->gender = $this->getGender($athlete); + $starter->category = $this->getCategory($athlete); $startList[] = $starter; } @@ -58,8 +58,8 @@ public function buildStartList(int $eventId): IFSCStartListResult */ private function selectTopByGender(array $startList): array { - $men = $this->filterByGender($startList, IFSCAthleteGender::MEN); - $women = $this->filterByGender($startList, IFSCAthleteGender::WOMEN); + $men = $this->filterByGender($startList, IFSCAthleteCategory::MEN); + $women = $this->filterByGender($startList, IFSCAthleteCategory::WOMEN); $selectedMen = $this->selectTopFromPool($men, array_slice($women, self::PER_GENDER_MAX)); $selectedWomen = $this->selectTopFromPool($women, array_slice($men, self::PER_GENDER_MAX)); @@ -101,9 +101,9 @@ private function sortByScore(): Closure } /** @return IFSCStarter[] */ - public function filterByGender(array $startList, IFSCAthleteGender $gender): array + public function filterByGender(array $startList, IFSCAthleteCategory $category): array { - return array_values(array_filter($startList, fn (IFSCStarter $starter): bool => $starter->gender === $gender)); + return array_values(array_filter($startList, fn (IFSCStarter $starter): bool => $starter->category === $category)); } private function normalizeInstagram(?string $instagram): ?string @@ -122,13 +122,13 @@ private function normalizeInstagram(?string $instagram): ?string /** * @param IFSCAthlete $athlete - * @return IFSCAthleteGender|null + * @return IFSCAthleteCategory|null */ - private function getGender(IFSCAthlete $athlete): ?IFSCAthleteGender + private function getCategory(IFSCAthlete $athlete): ?IFSCAthleteCategory { return match ($athlete->gender) { - 'male' => IFSCAthleteGender::MEN, - 'female' => IFSCAthleteGender::WOMEN, + 'male' => IFSCAthleteCategory::MEN, + 'female' => IFSCAthleteCategory::WOMEN, default => null, }; } diff --git a/src/Domain/StartList/IFSCStarter.php b/src/Domain/StartList/IFSCStarter.php index 3f8b82a..91cab53 100644 --- a/src/Domain/StartList/IFSCStarter.php +++ b/src/Domain/StartList/IFSCStarter.php @@ -8,7 +8,7 @@ namespace SportClimbing\IfscCalendar\Domain\StartList; use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDiscipline; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; final class IFSCStarter { @@ -18,7 +18,7 @@ public function __construct( public readonly string $firstName, public readonly string $lastName, public readonly string $country, - public ?IFSCAthleteGender $gender = null, + public ?IFSCAthleteCategory $category = null, public readonly array $disciplines = [], public float $score = 0, public ?string $photoUrl = null, diff --git a/src/Domain/Tags/IFSCParsedTags.php b/src/Domain/Tags/IFSCParsedTags.php index b68c191..dccf013 100644 --- a/src/Domain/Tags/IFSCParsedTags.php +++ b/src/Domain/Tags/IFSCParsedTags.php @@ -9,7 +9,7 @@ use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDiscipline; use SportClimbing\IfscCalendar\Domain\Event\IFSCEventTagsRegex as Tag; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\Round\IFSCRoundKind; final readonly class IFSCParsedTags @@ -29,8 +29,8 @@ ]; private const array CATEGORIES = [ - IFSCAthleteGender::WOMEN->value => Tag::WOMEN, - IFSCAthleteGender::MEN->value => Tag::MEN, + IFSCAthleteCategory::WOMEN->value => Tag::WOMEN, + IFSCAthleteCategory::MEN->value => Tag::MEN, ]; /** @param Tag[] $tags */ @@ -75,20 +75,20 @@ public function getRoundKind(): ?IFSCRoundKind return null; } - /** @return IFSCAthleteGender[] */ + /** @return IFSCAthleteCategory[] */ public function getCategories(): array { $categories = []; foreach (self::CATEGORIES as $name => $tag) { if ($this->hasTag($tag)) { - $categories[] = IFSCAthleteGender::from($name); + $categories[] = IFSCAthleteCategory::from($name); } } if (empty($categories)) { - $categories[] = IFSCAthleteGender::WOMEN; - $categories[] = IFSCAthleteGender::MEN; + $categories[] = IFSCAthleteCategory::WOMEN; + $categories[] = IFSCAthleteCategory::MEN; } return $categories; diff --git a/src/Infrastructure/Calendar/ICalCalendar.php b/src/Infrastructure/Calendar/ICalCalendar.php index ad4edeb..01f492d 100644 --- a/src/Infrastructure/Calendar/ICalCalendar.php +++ b/src/Infrastructure/Calendar/ICalCalendar.php @@ -98,7 +98,7 @@ private function convertStarterToArray(IFSCStarter $starter): array 'first_name' => $starter->firstName, 'last_name' => $starter->lastName, 'country' => $starter->country, - 'category' => $starter->gender?->value, + 'category' => $starter->category?->value, ]; } diff --git a/src/Infrastructure/Calendar/JsonCalendar.php b/src/Infrastructure/Calendar/JsonCalendar.php index c5c0a08..015fc93 100644 --- a/src/Infrastructure/Calendar/JsonCalendar.php +++ b/src/Infrastructure/Calendar/JsonCalendar.php @@ -14,7 +14,7 @@ use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDiscipline; use SportClimbing\IfscCalendar\Domain\Event\IFSCEvent; use SportClimbing\IfscCalendar\Domain\Round\IFSCRound; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\StartList\IFSCStarter; use Override; @@ -99,7 +99,7 @@ private function formatStarters(array $starters): array 'athlete_id' => $starter->athleteId, 'first_name' => $starter->firstName, 'last_name' => $starter->lastName, - 'gender' => $starter->gender, + 'category' => $starter->category, 'country' => $starter->country, 'photo_url' => $starter->photoUrl, 'instagram' => $starter->instagram, @@ -139,7 +139,7 @@ private function buildDisciplines(IFSCRound $round): array /** @return string[] */ private function buildCategories(IFSCRound $round): array { - return array_map(static fn (IFSCAthleteGender $category): string => $category->value, $round->categories); + return array_map(static fn (IFSCAthleteCategory $category): string => $category->value, $round->categories); } private function countryName(string $countryCode): string diff --git a/tests/unit/Domain/Round/IFSCSameStreamRoundsMergerTest.php b/tests/unit/Domain/Round/IFSCSameStreamRoundsMergerTest.php index d02f474..09de1bd 100644 --- a/tests/unit/Domain/Round/IFSCSameStreamRoundsMergerTest.php +++ b/tests/unit/Domain/Round/IFSCSameStreamRoundsMergerTest.php @@ -11,7 +11,7 @@ use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDiscipline; use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDisciplines; use SportClimbing\IfscCalendar\Domain\Round\IFSCRound; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\Round\IFSCRoundKind; use SportClimbing\IfscCalendar\Domain\Round\IFSCRoundNameNormalizer; use SportClimbing\IfscCalendar\Domain\Round\IFSCRoundStatus; @@ -37,14 +37,14 @@ protected function setUp(): void { $stream = new LiveStream(url: 'https://youtu.be/abc123'); - $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 14:00', '2025-05-10 15:30'); - $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:30', '2025-05-10 17:00'); + $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 14:00', '2025-05-10 15:30'); + $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:30', '2025-05-10 17:00'); $result = $this->merger->merge([$mens, $womens]); $this->assertCount(1, $result); $this->assertSame("Men's & Women's Lead Final", $result[0]->name); - $this->assertSame([IFSCAthleteGender::MEN, IFSCAthleteGender::WOMEN], $result[0]->categories); + $this->assertSame([IFSCAthleteCategory::MEN, IFSCAthleteCategory::WOMEN], $result[0]->categories); $this->assertSame($mens->startTime, $result[0]->startTime); $this->assertSame('2025-05-10T17:00:00+00:00', $result[0]->endTime->format(DATE_RFC3339)); $this->assertSame('https://youtu.be/abc123', $result[0]->liveStream->url); @@ -54,14 +54,14 @@ protected function setUp(): void { $stream = new LiveStream(url: 'https://youtu.be/abc123'); - $womens = $this->makeRound("Women's Boulder Qualification", [IFSCAthleteGender::WOMEN], IFSCRoundKind::QUALIFICATION, $stream, '2025-05-10 09:00', '2025-05-10 12:00'); - $mens = $this->makeRound("Men's Boulder Qualification", [IFSCAthleteGender::MEN], IFSCRoundKind::QUALIFICATION, $stream, '2025-05-10 12:00', '2025-05-10 15:00'); + $womens = $this->makeRound("Women's Boulder Qualification", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::QUALIFICATION, $stream, '2025-05-10 09:00', '2025-05-10 12:00'); + $mens = $this->makeRound("Men's Boulder Qualification", [IFSCAthleteCategory::MEN], IFSCRoundKind::QUALIFICATION, $stream, '2025-05-10 12:00', '2025-05-10 15:00'); $result = $this->merger->merge([$womens, $mens]); $this->assertCount(1, $result); $this->assertSame("Men's & Women's Boulder Qualification", $result[0]->name); - $this->assertSame([IFSCAthleteGender::MEN, IFSCAthleteGender::WOMEN], $result[0]->categories); + $this->assertSame([IFSCAthleteCategory::MEN, IFSCAthleteCategory::WOMEN], $result[0]->categories); } #[Test] public function rounds_with_different_stream_urls_are_not_merged(): void @@ -69,8 +69,8 @@ protected function setUp(): void $streamA = new LiveStream(url: 'https://youtu.be/aaa'); $streamB = new LiveStream(url: 'https://youtu.be/bbb'); - $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $streamA, '2025-05-10 14:00', '2025-05-10 15:30'); - $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $streamB, '2025-05-10 15:30', '2025-05-10 17:00'); + $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $streamA, '2025-05-10 14:00', '2025-05-10 15:30'); + $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $streamB, '2025-05-10 15:30', '2025-05-10 17:00'); $result = $this->merger->merge([$mens, $womens]); @@ -81,8 +81,8 @@ protected function setUp(): void { $noStream = new LiveStream(); - $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $noStream, '2025-05-10 14:00', '2025-05-10 15:30'); - $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $noStream, '2025-05-10 15:30', '2025-05-10 17:00'); + $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $noStream, '2025-05-10 14:00', '2025-05-10 15:30'); + $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $noStream, '2025-05-10 15:30', '2025-05-10 17:00'); $result = $this->merger->merge([$mens, $womens]); @@ -93,8 +93,8 @@ protected function setUp(): void { $stream = new LiveStream(url: 'https://youtu.be/abc123'); - $qual = $this->makeRound("Men's Lead Qualification", [IFSCAthleteGender::MEN], IFSCRoundKind::QUALIFICATION, $stream, '2025-05-10 09:00', '2025-05-10 12:00'); - $final = $this->makeRound("Women's Lead Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:00', '2025-05-10 17:00'); + $qual = $this->makeRound("Men's Lead Qualification", [IFSCAthleteCategory::MEN], IFSCRoundKind::QUALIFICATION, $stream, '2025-05-10 09:00', '2025-05-10 12:00'); + $final = $this->makeRound("Women's Lead Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:00', '2025-05-10 17:00'); $result = $this->merger->merge([$qual, $final]); @@ -105,8 +105,8 @@ protected function setUp(): void { $stream = new LiveStream(url: 'https://youtu.be/abc123'); - $lead = $this->makeRound("Men's Lead Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 14:00', '2025-05-10 15:30', IFSCDiscipline::LEAD); - $boulder = $this->makeRound("Women's Boulder Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:30', '2025-05-10 17:00', IFSCDiscipline::BOULDER); + $lead = $this->makeRound("Men's Lead Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 14:00', '2025-05-10 15:30', IFSCDiscipline::LEAD); + $boulder = $this->makeRound("Women's Boulder Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:30', '2025-05-10 17:00', IFSCDiscipline::BOULDER); $result = $this->merger->merge([$lead, $boulder]); @@ -117,8 +117,8 @@ protected function setUp(): void { $stream = new LiveStream(url: 'https://youtu.be/abc123'); - $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 14:00', '2025-05-10 15:30', status: IFSCRoundStatus::PROVISIONAL); - $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:30', '2025-05-10 17:00', status: IFSCRoundStatus::CONFIRMED); + $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 14:00', '2025-05-10 15:30', status: IFSCRoundStatus::PROVISIONAL); + $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $stream, '2025-05-10 15:30', '2025-05-10 17:00', status: IFSCRoundStatus::CONFIRMED); $result = $this->merger->merge([$mens, $womens]); @@ -131,9 +131,9 @@ protected function setUp(): void $otherStream = new LiveStream(url: 'https://youtu.be/other'); $noStream = new LiveStream(); - $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $sharedStream, '2025-05-10 14:00', '2025-05-10 15:30'); - $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteGender::WOMEN], IFSCRoundKind::FINAL, $sharedStream, '2025-05-10 15:30', '2025-05-10 17:00'); - $speed = $this->makeRound("Men's Speed Final", [IFSCAthleteGender::MEN], IFSCRoundKind::FINAL, $otherStream, '2025-05-10 18:00', '2025-05-10 19:00'); + $mens = $this->makeRound("Men's Lead Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $sharedStream, '2025-05-10 14:00', '2025-05-10 15:30'); + $womens = $this->makeRound("Women's Lead Final", [IFSCAthleteCategory::WOMEN], IFSCRoundKind::FINAL, $sharedStream, '2025-05-10 15:30', '2025-05-10 17:00'); + $speed = $this->makeRound("Men's Speed Final", [IFSCAthleteCategory::MEN], IFSCRoundKind::FINAL, $otherStream, '2025-05-10 18:00', '2025-05-10 19:00'); $boulderQual = $this->makeRound("Boulder Qualification", [], IFSCRoundKind::QUALIFICATION, $noStream, '2025-05-09 09:00', '2025-05-09 13:00'); $result = $this->merger->merge([$mens, $womens, $speed, $boulderQual]); diff --git a/tests/unit/Domain/StartList/IFSCStartListGeneratorTest.php b/tests/unit/Domain/StartList/IFSCStartListGeneratorTest.php index 5b80896..eb0679c 100644 --- a/tests/unit/Domain/StartList/IFSCStartListGeneratorTest.php +++ b/tests/unit/Domain/StartList/IFSCStartListGeneratorTest.php @@ -12,7 +12,7 @@ use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteResult; use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteService; use SportClimbing\IfscCalendar\Domain\Ranking\IFSCAthleteRankingCalculator; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\StartList\IFSCStarter; use SportClimbing\IfscCalendar\Domain\StartList\IFSCStartListGenerator; use SportClimbing\IfscCalendar\Domain\StartList\IFSCStartListProviderInterface; @@ -118,9 +118,9 @@ private function worldCupResult(int $rank, int $eventId): IFSCAthleteResult $this->assertSame([3, 1, 2], $athleteProvider->requestedAthleteIds); $this->assertSame([1, 2, 3], array_map(static fn (IFSCStarter $starter): int => $starter->athleteId, $startList)); - $this->assertSame(IFSCAthleteGender::WOMEN, $startList[0]->gender); - $this->assertSame(IFSCAthleteGender::WOMEN, $startList[1]->gender); - $this->assertSame(IFSCAthleteGender::WOMEN, $startList[2]->gender); + $this->assertSame(IFSCAthleteCategory::WOMEN, $startList[0]->category); + $this->assertSame(IFSCAthleteCategory::WOMEN, $startList[1]->category); + $this->assertSame(IFSCAthleteCategory::WOMEN, $startList[2]->category); $this->assertSame('https://photos/1', $startList[0]->photoUrl); $this->assertSame('https://photos/2', $startList[1]->photoUrl); @@ -149,8 +149,8 @@ private function worldCupResult(int $rank, int $eventId): IFSCAthleteResult $this->assertSame(50, $result->total); $this->assertCount(40, $startList); - $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::MEN); - $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::WOMEN); + $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::MEN); + $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::WOMEN); $this->assertCount(20, $menInList); $this->assertCount(20, $womenInList); @@ -196,8 +196,8 @@ private function worldCupResult(int $rank, int $eventId): IFSCAthleteResult $this->assertSame(40, $result->total); $this->assertCount(40, $startList); - $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::MEN); - $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::WOMEN); + $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::MEN); + $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::WOMEN); // Only 10 men exist, so all 10 should be included $this->assertCount(10, $menInList); @@ -236,8 +236,8 @@ private function worldCupResult(int $rank, int $eventId): IFSCAthleteResult $this->assertSame(40, $result->total); $this->assertCount(40, $startList); - $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::MEN); - $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::WOMEN); + $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::MEN); + $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::WOMEN); // 30 men (top 20 + 10 filling women shortfall) $this->assertCount(30, $menInList); @@ -270,8 +270,8 @@ private function worldCupResult(int $rank, int $eventId): IFSCAthleteResult $this->assertSame(15, $result->total); $this->assertCount(15, $startList); - $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::MEN); - $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->gender === IFSCAthleteGender::WOMEN); + $menInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::MEN); + $womenInList = array_filter($startList, fn (IFSCStarter $s): bool => $s->category === IFSCAthleteCategory::WOMEN); $this->assertCount(8, $menInList); $this->assertCount(7, $womenInList); diff --git a/tests/unit/Infrastructure/Calendar/CalendarSpeedRelayFormattingTest.php b/tests/unit/Infrastructure/Calendar/CalendarSpeedRelayFormattingTest.php index 388802f..4168f1c 100644 --- a/tests/unit/Infrastructure/Calendar/CalendarSpeedRelayFormattingTest.php +++ b/tests/unit/Infrastructure/Calendar/CalendarSpeedRelayFormattingTest.php @@ -15,7 +15,7 @@ use SportClimbing\IfscCalendar\Domain\Discipline\IFSCDisciplines; use SportClimbing\IfscCalendar\Domain\Event\IFSCEvent; use SportClimbing\IfscCalendar\Domain\Round\IFSCRound; -use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteGender; +use SportClimbing\IfscCalendar\Domain\Athlete\IFSCAthleteCategory; use SportClimbing\IfscCalendar\Domain\Round\IFSCRoundKind; use SportClimbing\IfscCalendar\Domain\Round\IFSCRoundStatus; use SportClimbing\IfscCalendar\Domain\Season\IFSCSeasonYear; @@ -59,7 +59,7 @@ private function createEventWithSpeedRelayRound(): IFSCEvent $roundEnd = new DateTimeImmutable('2026-09-01 11:30:00', $timeZone); $round = new IFSCRound( name: "Men's Speed Relay Qualification", - categories: [IFSCAthleteGender::MEN], + categories: [IFSCAthleteCategory::MEN], disciplines: new IFSCDisciplines([IFSCDiscipline::SPEED_RELAY]), kind: IFSCRoundKind::QUALIFICATION, liveStream: new LiveStream(url: 'https://youtube.com/watch?v=relay-test'),