setValue('2011-02-01')
->Field();
$expected = '1/02/2011 (today)';
$this->assertEquals($expected, $actual);
// Test today's date with time
$actual = DateField_Disabled::create('Test')
->setValue('2011-02-01 10:34:00')
->Field();
$this->assertEquals($expected, $actual);
}
public function testFieldWithDifferentDay()
{
// Test past
$actual = DateField_Disabled::create('Test')
->setValue('2011-01-27')
->Field();
$expected = '27/01/2011, 5 days ago';
$this->assertEquals($expected, $actual);
// Test future
$actual = DateField_Disabled::create('Test')
->setValue('2011-02-06')
->Field();
$expected = '6/02/2011, in 5 days';
$this->assertEquals($expected, $actual);
}
public function testFieldWithDifferentLocal()
{
// Test different local
$actual = DateField_Disabled::create('Test')
->setValue('2011-02-06')
->setHTML5(false)
->setLocale('de_DE')
->Field();
$expected = '06.02.2011, in 5 days';
$this->assertEquals($expected, $actual);
}
public function testFieldWithNonValue()
{
// Test none value
$actual = DateField_Disabled::create('Test')->Field();
$expected = '(not set)';
$this->assertEquals($expected, $actual);
$actual = DateField_Disabled::create('Test')->setValue('This is not a date')->Field();
$this->assertEquals($expected, $actual);
}
}