Formatted duration template variable and method, with tests.

Start writing Story help.
This commit is contained in:
Colin Kuskie 2009-03-07 00:01:41 +00:00
parent 925a218224
commit 4b1ec30748
4 changed files with 177 additions and 1 deletions

View file

@ -21,7 +21,7 @@ use Test::Deep;
use Data::Dumper;
my $tests = 1;
plan tests => 16
plan tests => 23
+ $tests
;
@ -32,6 +32,7 @@ my $session = WebGUI::Test->session;
my $class = 'WebGUI::Asset::Story';
my $loaded = use_ok($class);
my $story;
my $wgBday;
my $defaultNode = WebGUI::Asset->getDefault($session);
my $archive = $defaultNode->addChild({
@ -124,6 +125,19 @@ cmp_deeply(
'setPhotoData: wipes the stored data if nothing is passed'
);
############################################################
#
# formatDuration
#
############################################################
is($story->formatDuration(time() - (24*3600+15)), '1 Day(s)', 'formatDuration, 1 day');
is($story->formatDuration(time() - (48*3600+15)), '2 Day(s)', 'formatDuration, 2 day');
like($story->formatDuration(997966800), qr{Year.s.}, 'formatDuration: a long time ago');
is($story->formatDuration(time() - (3600+5)), '1 Hour(s)', 'formatDuration: 1 hour');
is($story->formatDuration(time() - (60+5)), '1 Minute(s)', 'formatDuration: 1 minute');
is($story->formatDuration(time() - (7200+120)), '2 Hour(s), 2 Minute(s)', 'formatDuration: 2 hours, 2 minutes');
############################################################
#
# viewTemplateVariables
@ -157,10 +171,13 @@ cmp_bag(
'viewTemplateVariables: keywords_loop is okay'
);
is ($viewVariables->{updatedTimeEpoch}, $story->get('revisionDate'), 'viewTemplateVariables: updatedTimeEpoch');
}
END {
$story->purge if $story;
$wgBday->purge if $wgBday;
$archive->purge if $archive;
WebGUI::VersionTag->getWorking($session)->rollback;
}