mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Use DatetimeImmutable instead of DateTime wherever possible
This commit is contained in:
parent
eebc373734
commit
235d572f8c
39 changed files with 222 additions and 112 deletions
|
@ -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!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class PartTest extends TestCase
|
|||
$part->addPartLot(
|
||||
(new PartLot())
|
||||
->setAmount(6)
|
||||
->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour')))
|
||||
->setExpirationDate(new \DateTimeImmutable('-1 hour'))
|
||||
);
|
||||
|
||||
$this->assertEqualsWithDelta(13.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
|
|
@ -73,7 +73,7 @@ class UserTest extends TestCase
|
|||
$codes = ['test', 'invalid', 'test'];
|
||||
$user->setBackupCodes($codes);
|
||||
// Backup Codes generation date must be changed!
|
||||
$this->assertInstanceOf(\DateTime::class, $user->getBackupCodesGenerationDate());
|
||||
$this->assertNotNull($user->getBackupCodesGenerationDate());
|
||||
$this->assertSame($codes, $user->getBackupCodes());
|
||||
|
||||
//Test what happens if we delete the backup keys
|
||||
|
|
|
@ -65,7 +65,7 @@ class PartLotProviderTest extends WebTestCase
|
|||
$this->target = new PartLot();
|
||||
$this->target->setDescription('Lot description');
|
||||
$this->target->setComment('Lot comment');
|
||||
$this->target->setExpirationDate(new \DateTime('1999-04-13'));
|
||||
$this->target->setExpirationDate(new \DateTimeImmutable('1999-04-13'));
|
||||
$this->target->setInstockUnknown(true);
|
||||
|
||||
$location = new StorageLocation();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue