fix: keep the calendar day tests independent of the current date
This commit is contained in:
1 parent
4b70d0e2b7
commit
dcd85bb911
1 file changed
+12
-6
@@ -546,10 +546,13 @@ class BookingControllerTest extends WebTestCase
|
|||||||
public function testPastDaysInTheCalendarAreMarkedButStillNavigable(): void
|
public function testPastDaysInTheCalendarAreMarkedButStillNavigable(): void
|
||||||
{
|
{
|
||||||
$this->client->loginUser($this->user('[email protected]'));
|
$this->client->loginUser($this->user('[email protected]'));
|
||||||
$yesterday = (new \DateTimeImmutable('today'))->modify('-1 day')->format('Y-m-d');
|
// Mid-month of last month rather than yesterday: on the 1st, yesterday is a spill-over
|
||||||
|
// day from the month before, and the out-of-month styling takes precedence over "past".
|
||||||
|
$selected = (new \DateTimeImmutable('first day of last month midnight'))->modify('+14 days');
|
||||||
|
$past = $selected->modify('-1 day')->format('Y-m-d');
|
||||||
|
|
||||||
$crawler = $this->client->request('GET', '/book/desk');
|
$crawler = $this->client->request('GET', '/book/desk?date='.$selected->format('Y-m-d'));
|
||||||
$cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $yesterday));
|
$cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $past));
|
||||||
|
|
||||||
self::assertCount(1, $cell);
|
self::assertCount(1, $cell);
|
||||||
self::assertSame('true', $cell->attr('aria-disabled'));
|
self::assertSame('true', $cell->attr('aria-disabled'));
|
||||||
@@ -559,10 +562,13 @@ class BookingControllerTest extends WebTestCase
|
|||||||
public function testFutureDaysInTheCalendarAreNotMarkedAsPast(): void
|
public function testFutureDaysInTheCalendarAreNotMarkedAsPast(): void
|
||||||
{
|
{
|
||||||
$this->client->loginUser($this->user('[email protected]'));
|
$this->client->loginUser($this->user('[email protected]'));
|
||||||
$tomorrow = (new \DateTimeImmutable('today'))->modify('+1 day')->format('Y-m-d');
|
// Mid-month of next month rather than tomorrow: on a month's last day, tomorrow falls
|
||||||
|
// outside the grid whenever that day is a Sunday.
|
||||||
|
$selected = (new \DateTimeImmutable('first day of next month midnight'))->modify('+14 days');
|
||||||
|
$future = $selected->modify('+1 day')->format('Y-m-d');
|
||||||
|
|
||||||
$crawler = $this->client->request('GET', '/book/desk');
|
$crawler = $this->client->request('GET', '/book/desk?date='.$selected->format('Y-m-d'));
|
||||||
$cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $tomorrow));
|
$cell = $crawler->filter(\sprintf('button[hx-get*="/book/desk/day/%s"]', $future));
|
||||||
|
|
||||||
self::assertCount(1, $cell);
|
self::assertCount(1, $cell);
|
||||||
self::assertNull($cell->attr('aria-disabled'));
|
self::assertNull($cell->attr('aria-disabled'));
|
||||||
|
|||||||
Reference in new issue
Block a user