test scheduled node controller returns 404 when user missing

This commit is contained in:
Yisroel Baum 2026-05-01 10:25:24 +03:00
parent f315db6d00
commit ed4440eec2
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -225,4 +225,28 @@ class ScheduledNodeControllerTest extends TestCase
$body = json_decode((string) $response->getBody(), true);
$this->assertEquals([], $body);
}
public function test_returns_404_when_use_case_throws_domain_exception(): void
{
$unknownUser = new User(
id: 999,
email: new EmailAddress('ghost@test.com'),
passwordHash: '',
isAdmin: false,
);
$response = $this->controller->getScheduledNodes(
$this->makeRequest('2025-01-02', $unknownUser),
new Response(),
$this->getTodaysSchedule,
);
$this->assertEquals(404, $response->getStatusCode());
$body = json_decode((string) $response->getBody(), true);
$this->assertArrayHasKey('error', $body);
$this->assertEquals(
'User with id: 999 doesnt exist',
$body['error']
);
}
}