mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fixed tests
This commit is contained in:
parent
a70de91b33
commit
e9693467bf
@ -324,41 +324,4 @@ class DBDateTest extends SapphireTest
|
||||
|
||||
DBDatetime::clear_mock_now();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see testFormatFromSettings
|
||||
* @return array
|
||||
*/
|
||||
public function dataTestFormatFromSettings()
|
||||
{
|
||||
return [
|
||||
['2000-12-31', '31/12/2000'],
|
||||
['31-12-2000', '31/12/2000'],
|
||||
['2014-04-01', '01/04/2014'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestFormatFromSettings
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
*/
|
||||
public function testFormatFromSettings($from, $to)
|
||||
{
|
||||
$this->suppressNotices();
|
||||
$member = new Member();
|
||||
$member->DateFormat = 'dd/MM/y';
|
||||
|
||||
$date = DBField::create_field('Date', $from);
|
||||
$this->assertEquals($to, $date->FormatFromSettings($member));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that FormatFromSettings without a member defaults to Nice()
|
||||
*/
|
||||
public function testFormatFromSettingsEmpty()
|
||||
{
|
||||
$date = DBfield::create_field('Date', '2000-12-31');
|
||||
$this->assertEquals('31/12/2000', $date->FormatFromSettings());
|
||||
}
|
||||
}
|
||||
|
@ -205,40 +205,4 @@ class DBDatetimeTest extends SapphireTest
|
||||
DBDatetime::clear_mock_now();
|
||||
}
|
||||
|
||||
public function dataTestFormatFromSettings()
|
||||
{
|
||||
return [
|
||||
['2000-12-31 10:11:01', '31/12/2000 10:11:01'],
|
||||
['2000-12-31 1:11:01', '31/12/2000 01:11:01'],
|
||||
['2000-12-12 1:11:01', '12/12/2000 01:11:01'],
|
||||
['2000-12-31', '31/12/2000 00:00:00'],
|
||||
['2014-04-01 10:11:01', '01/04/2014 10:11:01']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestFormatFromSettings
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
*/
|
||||
public function testFormatFromSettings($from, $to)
|
||||
{
|
||||
$member = new Member();
|
||||
$member->DateFormat = 'dd/MM/y';
|
||||
$member->TimeFormat = 'HH:mm:ss';
|
||||
|
||||
$date = DBDatetime::create_field('Datetime', $from);
|
||||
$this->assertEquals($to, $date->FormatFromSettings($member));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that FormatFromSettings without a member defaults to Nice()
|
||||
*/
|
||||
public function testFormatFromSettingsEmpty()
|
||||
{
|
||||
$date = DBDatetime::create_field('Datetime', '2000-12-31 10:11:01');
|
||||
|
||||
// note: Some localisation packages exclude the ',' in default medium format
|
||||
$this->assertRegExp('#31/12/2000(,)? 10:11:01 AM#', $date->FormatFromSettings());
|
||||
}
|
||||
}
|
||||
|
@ -56,35 +56,4 @@ class DBTimeTest extends SapphireTest
|
||||
$time = DBTime::create_field('Time', '17:15:55');
|
||||
$this->assertEquals('5:15 PM', $time->Short());
|
||||
}
|
||||
|
||||
public function dataTestFormatFromSettings()
|
||||
{
|
||||
return [
|
||||
['10:11:01', '10:11:01 (AM)'],
|
||||
['21:11:01', '9:11:01 (PM)'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestFormatFromSettings
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
*/
|
||||
public function testFormatFromSettings($from, $to)
|
||||
{
|
||||
$member = new Member();
|
||||
$member->TimeFormat = 'h:mm:ss (a)';
|
||||
|
||||
$date = DBTime::create_field('Time', $from);
|
||||
$this->assertEquals($to, $date->FormatFromSettings($member));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that FormatFromSettings without a member defaults to Nice()
|
||||
*/
|
||||
public function testFormatFromSettingsEmpty()
|
||||
{
|
||||
$date = DBTime::create_field('Time', '10:11:01');
|
||||
$this->assertEquals('10:11:01 AM', $date->FormatFromSettings());
|
||||
}
|
||||
}
|
||||
|
@ -395,15 +395,6 @@ class MemberTest extends FunctionalTest
|
||||
$member->PasswordExpiry = date('Y-m-d', time() + 86400);
|
||||
$this->assertFalse($member->isPasswordExpired());
|
||||
}
|
||||
|
||||
public function testMemberWithNoDateFormatFallsbackToGlobalLocaleDefaultFormat()
|
||||
{
|
||||
// Note: All default strings are based on locale defaults for en_US
|
||||
$member = $this->objFromFixture(Member::class, 'noformatmember');
|
||||
$this->assertEquals('MMM d, y', $member->DateFormat);
|
||||
$this->assertEquals('h:mm:ss a', $member->TimeFormat);
|
||||
}
|
||||
|
||||
public function testInGroups()
|
||||
{
|
||||
$staffmember = $this->objFromFixture(Member::class, 'staffmember');
|
||||
|
Loading…
Reference in New Issue
Block a user