Beispiel #1
0
 public function testFilterTo()
 {
     $to = new \DateTime('2010-10-12 08:30:00');
     $filter = new DateRange(null, $to);
     // test between
     $this->assertEquals(new \DateTime('2010-10-11 06:00:00'), $filter->apply('2010-10-11 06:00:00'));
     // test to
     $this->assertEquals(new \DateTime('2010-10-12 08:29:59'), $filter->apply('2010-10-12 08:29:59'));
     $this->assertEquals(new \DateTime('2010-10-12 08:30:00'), $filter->apply('2010-10-12 08:30:00'));
     $this->assertEquals(false, $filter->apply('2010-10-12 08:30:01'));
     // test error message
     $this->assertErrorMessage($filter->getErrorMessage());
 }
Beispiel #2
0
 public function testErrorMessageIsCustomizable()
 {
     $constraint = new DateRange('today', '+3days', 'CUSTOM!');
     $this->assertSame('[field] CUSTOM!', $constraint->getErrorMessage('field'));
 }
Beispiel #3
0
 public function testIsGettingErrorMessage()
 {
     $constraint = new DateRange('today', '+3 days');
     $this->assertFalse($constraint->validate('yesterday'));
     $this->assertEquals('[field] Date is not between "today" and "+3 days"', $constraint->getErrorMessage('field'));
 }