|
|
@@ -139,6 +139,34 @@ final class CrudPagesTest extends AppTestCase
|
|
|
self::assertSame('success', $flash[0]['type']);
|
|
|
}
|
|
|
|
|
|
+ public function testManualBlockCreateExpandsBareDateToEndOfDay(): void
|
|
|
+ {
|
|
|
+ // The form uses <input type="date">, which submits "YYYY-MM-DD".
|
|
|
+ // The controller must expand that to T23:59:59Z so the block
|
|
|
+ // covers the full selected calendar day.
|
|
|
+ $this->enqueueApiResponse(201, ['id' => 100, 'kind' => 'ip', 'ip' => '203.0.113.5']);
|
|
|
+ $token = $this->csrfFromManualBlocks();
|
|
|
+
|
|
|
+ $body = http_build_query([
|
|
|
+ 'csrf_token' => $token,
|
|
|
+ 'kind' => 'ip',
|
|
|
+ 'ip' => '203.0.113.5',
|
|
|
+ 'reason' => 'eod test',
|
|
|
+ 'expires_at' => '2026-12-31',
|
|
|
+ ]);
|
|
|
+ $response = $this->request('POST', '/app/manual-blocks', [], $body, 'application/x-www-form-urlencoded');
|
|
|
+ self::assertSame(303, $response->getStatusCode());
|
|
|
+
|
|
|
+ // The last captured outgoing call is the POST to the api;
|
|
|
+ // earlier history entries are the GETs from csrfFromManualBlocks.
|
|
|
+ $last = end($this->apiHistory);
|
|
|
+ self::assertNotFalse($last);
|
|
|
+ self::assertSame('POST', $last['request']->getMethod());
|
|
|
+ $payload = json_decode((string) $last['request']->getBody(), true);
|
|
|
+ self::assertIsArray($payload);
|
|
|
+ self::assertSame('2026-12-31T23:59:59Z', $payload['expires_at']);
|
|
|
+ }
|
|
|
+
|
|
|
public function testManualBlockCreateValidationErrorFlashesField(): void
|
|
|
{
|
|
|
// The MockHandler is FIFO: the GET inside csrfFromManualBlocks
|