Fixed Form Date and DateTime to properly handle mysql and epoch times. Added tests to make sure they work.
This commit is contained in:
parent
a81999d5ea
commit
e7f5948ce1
7 changed files with 52 additions and 14 deletions
|
|
@ -44,7 +44,7 @@ my $testBlock = [
|
|||
|
||||
my $formType = 'date';
|
||||
|
||||
my $numTests = 12 + scalar @{ $testBlock } ;
|
||||
my $numTests = 15 + scalar @{ $testBlock } ;
|
||||
|
||||
|
||||
plan tests => $numTests;
|
||||
|
|
@ -94,7 +94,10 @@ $html = join "\n",
|
|||
@inputs = $forms[0]->inputs;
|
||||
$input = $inputs[0];
|
||||
is($input->name, 'preDateValue', 'Checking input name');
|
||||
#is($input->value, 1217608466, 'Checking default value');
|
||||
TODO: {
|
||||
local $TODO = "Figure out why this is returning a MySQL value instead of an epoch.";
|
||||
is($input->value, 1217608466, 'Checking default value');
|
||||
}
|
||||
is($input->{size}, 10, 'Checking size param, set');
|
||||
is($input->{maxlength}, 10, 'Checking maxlength param, set');
|
||||
|
||||
|
|
@ -108,5 +111,9 @@ my $date2 = WebGUI::Form::Date->new($session, {'defaultValue' => '2008-08-01 16:
|
|||
is($date2->getValue(1217608466), '2008-08-01 11:34:26', "Epoch to MySQL");
|
||||
is($date2->getValue('2008-08-01 11:34:26'), '2008-08-01 11:34:26', "MySQL to MySQL");
|
||||
|
||||
my $date2 = WebGUI::Form::Date->new($session);
|
||||
is($date2->getValue(1217608466), 1217608466, "Default Epoch to Epoch");
|
||||
is($date2->getValue('2008-08-01 11:34:26'), 1217608466, "Default MySQL to Epoch");
|
||||
|
||||
__END__
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
my $formType = 'datetime';
|
||||
|
||||
my $numTests = 14;
|
||||
my $numTests = 15;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
|
|
@ -87,14 +87,18 @@ is($input->{maxlength}, 19, 'Checking maxlength param, set');
|
|||
#WebGUI::Form_Checking::auto_check($session, $formType, $testBlock);
|
||||
|
||||
my $date1 = WebGUI::Form::DateTime->new($session, {'defaultValue' => time()});
|
||||
$session->user->profileField( 'timeZone' , 'American/Chicago');
|
||||
$session->user->profileField( 'timeZone' , 'America/Chicago');
|
||||
is($date1->getValue(1217608466), 1217608466, "Epoch to Epch");
|
||||
is($date1->getValue('2008-08-01 16:34:26'), $session->datetime->setToEpoch("2008-08-01 16:34:26"), "MySQL to Epoch");
|
||||
|
||||
my $date2 = WebGUI::Form::DateTime->new($session);
|
||||
is($date2->getValue(1217608466), 1217608466, "Default Epoch to Epch");
|
||||
is($date2->getValue('2008-08-01 16:34:26'), $session->datetime->setToEpoch("2008-08-01 16:34:26"), "Default MySQL to Epoch");
|
||||
|
||||
#Dates to MySQL
|
||||
my $date2 = WebGUI::Form::DateTime->new($session, {'defaultValue' => '2008-08-01 16:34:26'});
|
||||
is($date2->getValue(1217608466), '2008-08-01 11:34:26', "Epoch to MySQL");
|
||||
is($date2->getValue('2008-08-01 11:34:26'), '2008-08-01 11:34:26', "MySQL to MySQL");
|
||||
my $date3 = WebGUI::Form::DateTime->new($session, {'defaultValue' => '2008-08-01 16:34:26'});
|
||||
is($date3->getValue(1217608466), '2008-08-01 11:34:26', "Epoch to MySQL");
|
||||
is($date3->getValue('2008-08-01 11:34:26'), '2008-08-01 16:34:26', "MySQL to MySQL");#UTC is 5 hours ahead of Chicago
|
||||
|
||||
__END__
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue