Skip to content

Commit 9385fa0

Browse files
ISSUE #1670: Fix Undefined array key in BuildRewindHtmlCommandHandler.php
1 parent c1e6350 commit 9385fa0

File tree

5 files changed

+753
-38
lines changed

5 files changed

+753
-38
lines changed

composer.lock

Lines changed: 38 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Application/Build/BuildRewindHtml/BuildRewindHtmlCommandHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ public function handle(Command $command): void
339339
);
340340
}
341341
}
342+
if (1 === count($availableRewindOptions)) {
343+
// "All time" option is the only one. No need to compare rewinds.
344+
return;
345+
}
342346

343347
foreach ($availableRewindOptions as $availableRewindOptionLeft) {
344348
$defaultRewindYearToCompareWith = $availableRewindOptions[0] != $availableRewindOptionLeft ? $availableRewindOptions[0] : $availableRewindOptions[1];

tests/Application/Build/BuildRewindHtml/BuildRewindHtmlCommandHandlerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,19 @@ public function testHandle(): void
2929
$this->commandBus->dispatch(new BuildRewindHtml(SerializableDateTime::fromString('2025-10-01T00:00:00+00:00')));
3030
$this->assertFileSystemWrites($this->getContainer()->get('build.storage'));
3131
}
32+
33+
public function testHandleWhenNoRewindsToCompare(): void
34+
{
35+
$this->getContainer()->get(ActivityWithRawDataRepository::class)->add(ActivityWithRawData::fromState(
36+
ActivityBuilder::fromDefaults()
37+
->withActivityId(ActivityId::random())
38+
->withSportType(SportType::WALK)
39+
->withStartDateTime(SerializableDateTime::fromString('2023-03-01'))
40+
->build(),
41+
[]
42+
));
43+
44+
$this->commandBus->dispatch(new BuildRewindHtml(SerializableDateTime::fromString('2023-10-01T00:00:00+00:00')));
45+
$this->assertFileSystemWrites($this->getContainer()->get('build.storage'));
46+
}
3247
}

0 commit comments

Comments
 (0)