Skip to content

Commit

Permalink
[BUGFIX] Extract warmup request id from query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Aug 11, 2023
1 parent d1d248c commit 8ab88f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 3 additions & 7 deletions Classes/ValueObject/Request/WarmupRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,24 @@
final class WarmupRequest
{
/**
* @var non-empty-string
*/
private readonly string $id;

/**
* @param non-empty-string $requestId
* @param list<SiteWarmupRequest> $sites
* @param list<PageWarmupRequest> $pages
*/
public function __construct(
private readonly string $requestId,
private readonly array $sites = [],
private readonly array $pages = [],
private readonly RequestConfiguration $configuration = new RequestConfiguration(),
) {
$this->id = uniqid('_', true);
}

/**
* @return non-empty-string
*/
public function getId(): string
{
return $this->id;
return $this->requestId;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ protected function setUp(): void
);
$this->subject = new Src\Http\Message\Event\WarmupFinishedEvent(
new Src\ValueObject\Request\WarmupRequest(
'foo',
[
new Src\ValueObject\Request\SiteWarmupRequest($site, [0, 1]),
],
Expand Down Expand Up @@ -158,7 +159,7 @@ public function getDataIncludesEmptyMessageIfNoSitesOrPagesWereRequested(): void
$message = Src\Configuration\Localization::translate('notification.message.empty');

$subject = new Src\Http\Message\Event\WarmupFinishedEvent(
new Src\ValueObject\Request\WarmupRequest(),
new Src\ValueObject\Request\WarmupRequest('foo'),
$this->cacheWarmupResult,
);

Expand All @@ -172,6 +173,7 @@ public function getDataThrowsExceptionIfRequestedPageDoesNotExist(): void
{
$subject = new Src\Http\Message\Event\WarmupFinishedEvent(
new Src\ValueObject\Request\WarmupRequest(
'foo',
pages: [
new Src\ValueObject\Request\PageWarmupRequest(99),
],
Expand Down
9 changes: 7 additions & 2 deletions Tests/Unit/ValueObject/Request/WarmupRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ protected function setUp(): void
);
$this->page = new Src\ValueObject\Request\PageWarmupRequest(7);
$this->configuration = new Src\ValueObject\Request\RequestConfiguration(50, 'foo');
$this->subject = new Src\ValueObject\Request\WarmupRequest([$this->site], [$this->page], $this->configuration);
$this->subject = new Src\ValueObject\Request\WarmupRequest(
'foo',
[$this->site],
[$this->page],
$this->configuration,
);
}

#[Framework\Attributes\Test]
public function getIdReturnsId(): void
{
self::assertNotEmpty($this->subject->getId());
self::assertSame('foo', $this->subject->getId());
}

#[Framework\Attributes\Test]
Expand Down

0 comments on commit 8ab88f5

Please sign in to comment.