View | Details | Raw Unified | Return to bug 20144
Collapse All | Expand All

(-)a/t/db_dependent/Koha/GetDailyQuote.t (-10 / +8 lines)
Lines 40-56 $dbh->do("DELETE FROM quotes"); Link Here
40
40
41
# Ids not starting with 1 to reflect possible deletes, this acts as a regression test for bug 11297
41
# Ids not starting with 1 to reflect possible deletes, this acts as a regression test for bug 11297
42
$dbh->do("INSERT INTO `quotes` VALUES
42
$dbh->do("INSERT INTO `quotes` VALUES
43
(6,'George Washington','To be prepared for war is one of the most effectual means of preserving peace.','0000-00-00 00:00:00'),
43
(6,'George Washington','To be prepared for war is one of the most effectual means of preserving peace.',NOW()),
44
(7,'Thomas Jefferson','When angry, count ten, before you speak; if very angry, an hundred.','0000-00-00 00:00:00'),
44
(7,'Thomas Jefferson','When angry, count ten, before you speak; if very angry, an hundred.',NOW()),
45
(8,'Abraham Lincoln','Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.','0000-00-00 00:00:00'),
45
(8,'Abraham Lincoln','Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.',NOW()),
46
(9,'Abraham Lincoln','I have always found that mercy bears richer fruits than strict justice.','0000-00-00 00:00:00'),
46
(9,'Abraham Lincoln','I have always found that mercy bears richer fruits than strict justice.',NOW()),
47
(10,'Andrew Johnson','I feel incompetent to perform duties...which have been so unexpectedly thrown upon me.','0000-00-00 00:00:00');");
47
(10,'Andrew Johnson','I feel incompetent to perform duties...which have been so unexpectedly thrown upon me.',NOW());");
48
48
49
my $expected_quote = {
49
my $expected_quote = {
50
    id          => 8,
50
    id          => 8,
51
    source      => 'Abraham Lincoln',
51
    source      => 'Abraham Lincoln',
52
    text        => 'Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.',
52
    text        => 'Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.',
53
    timestamp   => '0000-00-00 00:00:00',
53
    timestamp   => dt_from_string,
54
};
54
};
55
55
56
my $quote = GetDailyQuote('id'=>8);
56
my $quote = GetDailyQuote('id'=>8);
Lines 61-68 $quote = GetDailyQuote('random'=>1); Link Here
61
ok($quote, "Got a random quote.");
61
ok($quote, "Got a random quote.");
62
cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0');
62
cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0');
63
63
64
$dbh->do("UPDATE quotes SET timestamp = '0000-00-00 00:00:00';");
64
my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string->add( hours => 1 )); # To make it the last one
65
my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string());
66
my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?';
65
my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?';
67
my $sth = C4::Context->dbh->prepare($query);
66
my $sth = C4::Context->dbh->prepare($query);
68
$sth->execute( $timestamp , $expected_quote->{'id'});
67
$sth->execute( $timestamp , $expected_quote->{'id'});
Lines 79-85 $quote = eval {GetDailyQuote();}; Link Here
79
is( $@, '', 'GetDailyQuote does not die if no quote exist' );
78
is( $@, '', 'GetDailyQuote does not die if no quote exist' );
80
is_deeply( $quote, {}, 'GetDailyQuote return an empty hashref is no quote exist'); # Is it what we expect?
79
is_deeply( $quote, {}, 'GetDailyQuote return an empty hashref is no quote exist'); # Is it what we expect?
81
$dbh->do(q|INSERT INTO `quotes` VALUES
80
$dbh->do(q|INSERT INTO `quotes` VALUES
82
    (6,'George Washington','To be prepared for war is one of the most effectual means of preserving peace.','0000-00-00 00:00:00')
81
    (6,'George Washington','To be prepared for war is one of the most effectual means of preserving peace.',NOW())
83
|);
82
|);
84
83
85
$quote = GetDailyQuote();
84
$quote = GetDailyQuote();
86
- 

Return to bug 20144