Skip to content

Commit 5611b58

Browse files
committed
test: fix determinism of CacheTest
1 parent efe179f commit 5611b58

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/system/Router/Attributes/CacheTest.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@ protected function setUp(): void
3333
{
3434
parent::setUp();
3535

36-
// Clear cache before each test
3736
cache()->clean();
38-
37+
Services::resetSingle('response');
3938
Time::setTestNow('2026-01-10 12:00:00');
4039
}
4140

4241
protected function tearDown(): void
4342
{
4443
parent::tearDown();
4544

45+
cache()->clean();
46+
Services::resetSingle('response');
4647
Time::setTestNow();
4748
}
4849

@@ -215,11 +216,15 @@ private function createMockRequest(string $method, string $path, string $query =
215216

216217
$request = $this->getMockBuilder(IncomingRequest::class)
217218
->setConstructorArgs([$config, $uri, null, $userAgent])
218-
->onlyMethods(['isCLI'])
219+
->onlyMethods(['isCLI', 'withMethod', 'getMethod'])
219220
->getMock();
220221
$request->method('isCLI')->willReturn(false);
221-
$request->setMethod($method);
222+
$request->method('withMethod')->willReturnCallback(static function ($method) use ($request) {
223+
$request->method('getMethod')->willReturn($method);
224+
225+
return $request;
226+
});
222227

223-
return $request;
228+
return $request->withMethod($method);
224229
}
225230
}

0 commit comments

Comments
 (0)