Use DatetimeImmutable instead of DateTime wherever possible

This commit is contained in:
Jan Böhmer 2024-06-22 17:36:54 +02:00
parent eebc373734
commit 235d572f8c
39 changed files with 222 additions and 112 deletions

View file

@ -33,12 +33,11 @@ class PartLotTest extends TestCase
$lot = new PartLot();
$this->assertNull($lot->isExpired(), 'Lot must be return null when no Expiration date is set!');
$datetime = new DateTime();
$lot->setExpirationDate($datetime->setTimestamp(strtotime('now +1 hour')));
$lot->setExpirationDate(new \DateTimeImmutable('+1 hour'));
$this->assertFalse($lot->isExpired(), 'Lot with expiration date in the future must not be expired!');
$lot->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour')));
$lot->setExpirationDate(new \DateTimeImmutable('-1 hour'));
$this->assertTrue($lot->isExpired(), 'Lot with expiration date in the past must be expired!');
}
}