Fix test: use fixed date instead of 'yesterday'

This commit is contained in:
Julien Fastré 2023-08-31 11:12:12 +02:00
parent b85cd1b994
commit 2a9e461d6f
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -28,7 +28,7 @@ final class BirthdateValidatorTest extends ConstraintValidatorTestCase
{ {
public function testTomorrowInvalid() public function testTomorrowInvalid()
{ {
$bornAfter = new DateTime('+2 days'); $bornAfter = new DateTime('2023-08-31');
$this->validator->validate($bornAfter, $this->createConstraint()); $this->validator->validate($bornAfter, $this->createConstraint());
$this->buildViolation('msg') $this->buildViolation('msg')
->setParameter('%date%', (new DateTime('2023-08-29'))->format('d-m-Y')) ->setParameter('%date%', (new DateTime('2023-08-29'))->format('d-m-Y'))
@ -38,7 +38,7 @@ final class BirthdateValidatorTest extends ConstraintValidatorTestCase
public function testValidateTodayInvalid() public function testValidateTodayInvalid()
{ {
$bornToday = new DateTime('now'); $bornToday = new DateTime('2023-08-30');
$this->validator->validate($bornToday, $this->createConstraint()); $this->validator->validate($bornToday, $this->createConstraint());
$this->buildViolation('msg') $this->buildViolation('msg')
->setParameter('%date%', (new DateTime('2023-08-29'))->format('d-m-Y')) ->setParameter('%date%', (new DateTime('2023-08-29'))->format('d-m-Y'))
@ -59,7 +59,7 @@ final class BirthdateValidatorTest extends ConstraintValidatorTestCase
public function testValidateYesterdayValid() public function testValidateYesterdayValid()
{ {
$bornYesterday = new DateTime('yesterday'); $bornYesterday = new DateTime('2023-08-29');
$this->validator->validate($bornYesterday, $this->createConstraint()); $this->validator->validate($bornYesterday, $this->createConstraint());
$this->assertNoViolation(); $this->assertNoViolation();
} }