Skip to content

Commit b0f3a65

Browse files
committed
Merge remote-tracking branch 'origin/2025.4' into 2026.x
2 parents 09e997f + 4ae38ac commit b0f3a65

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/Mercure/Service/UrlService.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
public function getServerSideUrl(): string
3333
{
3434
if (empty($this->serverSideUrl)) {
35-
return $this->getDefaultServerUrl();
35+
throw new LogicException('Mercure server URL is not configured.');
3636
}
3737

3838
return $this->serverSideUrl;
@@ -47,11 +47,6 @@ public function getClientSideUrl(): string
4747
return str_replace(Mercure::HOST_PLACEHOLDER->value, $this->getHostUrl(), $this->clientSideUrl);
4848
}
4949

50-
private function getDefaultServerUrl(): string
51-
{
52-
return $this->getHostUrl() . '/hub/.well-known/mercure';
53-
}
54-
5550
private function getDefaultClientUrl(): string
5651
{
5752
return $this->getHostUrl() . '/hub';

tests/Unit/Mercure/Service/UrlServiceTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ public function testGetServerSideUrlWithCustomUrl(): void
2828
$this->assertSame('https://custom/mercure', $service->getServerSideUrl());
2929
}
3030

31-
public function testGetServerSideUrlWithDefault(): void
31+
public function testGetServerSideUrlThrowsWhenNotConfigured(): void
3232
{
33-
$service = new UrlService(
34-
null,
35-
null,
36-
$this->createRequestStackWithRequest('https://example.com')
37-
);
33+
$service = new UrlService(null, null, new RequestStack());
3834

39-
$this->assertSame('https://example.com/hub/.well-known/mercure', $service->getServerSideUrl());
35+
$this->expectException(LogicException::class);
36+
$this->expectExceptionMessage('Mercure server URL is not configured.');
37+
$service->getServerSideUrl();
4038
}
4139

4240
public function testGetClientSideUrlWithCustomUrlReplacesPlaceholder(): void
@@ -66,18 +64,19 @@ public function testThrowsLogicExceptionWithoutRequest(): void
6664
$service = new UrlService(null, null, new RequestStack());
6765

6866
$this->expectException(LogicException::class);
69-
$service->getServerSideUrl();
67+
$this->expectExceptionMessage('Mercure fallback URL resolution requires an active HTTP request.');
68+
$service->getClientSideUrl();
7069
}
7170

72-
public function testDefaultUrlIncludesNonStandardPort(): void
71+
public function testDefaultClientUrlIncludesNonStandardPort(): void
7372
{
7473
$service = new UrlService(
7574
null,
7675
null,
7776
$this->createRequestStackWithRequest('http://localhost:8080')
7877
);
7978

80-
$this->assertSame('http://localhost:8080/hub/.well-known/mercure', $service->getServerSideUrl());
79+
$this->assertSame('http://localhost:8080/hub', $service->getClientSideUrl());
8180
}
8281

8382
private function createRequestStackWithRequest(string $uri): RequestStack

0 commit comments

Comments
 (0)