Fixed test which heavily depended on timing of the assertation functions

This caused a lot of false positive test failures.
This commit is contained in:
Jan Böhmer 2022-07-23 23:07:51 +02:00
parent 3470a5fa5d
commit dd38749081

View file

@ -88,10 +88,12 @@ class UserTest extends TestCase
public function testSetBackupCodes(): void
{
$user = new User();
$this->assertNull($user->getBackupCodesGenerationDate());
$codes = ['test', 'invalid', 'test'];
$user->setBackupCodes($codes);
// Backup Codes generation date must be changed!
$this->assertEqualsWithDelta(new DateTime(), $user->getBackupCodesGenerationDate(), 0.1);
$this->assertInstanceOf(\DateTime::class, $user->getBackupCodesGenerationDate());
$this->assertSame($codes, $user->getBackupCodes());
//Test what happens if we delete the backup keys