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

(-)a/t/db_dependent/Koha/Quotes.t (-12 / +11 lines)
Lines 39-53 $schema->storage->txn_begin; Link Here
39
my $dbh = C4::Context->dbh;
39
my $dbh = C4::Context->dbh;
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
my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string()); #???
42
my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string());
43
my $quote_1 = Koha::Quote->new({ id => 6, source => 'George Washington', text => 'To be prepared for war is one of the most effectual means of preserving peace.', timestamp =>  $timestamp })->store;
43
my $quote_1 = Koha::Quote->new({ source => 'George Washington', text => 'To be prepared for war is one of the most effectual means of preserving peace.', timestamp =>  $timestamp })->store;
44
my $quote_2 = Koha::Quote->new({ id => 7, source => 'Thomas Jefferson', text => 'When angry, count ten, before you speak; if very angry, an hundred.', timestamp =>  $timestamp })->store;
44
my $quote_2 = Koha::Quote->new({ source => 'Thomas Jefferson', text => 'When angry, count ten, before you speak; if very angry, an hundred.', timestamp =>  $timestamp })->store;
45
my $quote_3 = Koha::Quote->new({ id => 8, source => 'Abraham Lincoln', 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', timestamp =>  $timestamp })->store;
45
my $quote_3 = Koha::Quote->new({ source => 'Abraham Lincoln', 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', timestamp =>  $timestamp })->store;
46
my $quote_4 = Koha::Quote->new({ id => 9, source => 'Abraham Lincoln', text => 'I have always found that mercy bears richer fruits than strict justice.', timestamp =>  $timestamp })->store;
46
my $quote_4 = Koha::Quote->new({ source => 'Abraham Lincoln', text => 'I have always found that mercy bears richer fruits than strict justice.', timestamp =>  $timestamp })->store;
47
my $quote_5 = Koha::Quote->new({ id => 10, source => 'Andrew Johnson', text => 'I feel incompetent to perform duties...which have been so unexpectedly thrown upon me.', timestamp =>  $timestamp })->store;
47
my $quote_5 = Koha::Quote->new({ source => 'Andrew Johnson', text => 'I feel incompetent to perform duties...which have been so unexpectedly thrown upon me.', timestamp =>  $timestamp })->store;
48
48
49
my $expected_quote = {
49
my $expected_quote = {
50
    id          => 8,
50
    id          => $quote_3->id,
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   => dt_from_string,
53
    timestamp   => dt_from_string,
Lines 75-84 $quote = eval {Koha::Quote->get_daily_quote();}; Link Here
75
is( $@, '', 'get_daily_quote does not die if no quote exist' );
75
is( $@, '', 'get_daily_quote does not die if no quote exist' );
76
is_deeply( $quote, {}, 'get_daily_quote return an empty hashref is no quote exist'); # Is it what we expect?
76
is_deeply( $quote, {}, 'get_daily_quote return an empty hashref is no quote exist'); # Is it what we expect?
77
77
78
my $quote_6 = Koha::Quote->new({ id => 6, source => 'George Washington', text => 'To be prepared for war is one of the most effectual means of preserving peace.', timestamp =>  dt_from_string() })->store;
78
my $quote_6 = Koha::Quote->new({ source => 'George Washington', text => 'To be prepared for war is one of the most effectual means of preserving peace.', timestamp =>  dt_from_string() })->store;
79
79
80
$quote = Koha::Quote->get_daily_quote();
80
$quote = Koha::Quote->get_daily_quote();
81
is( $quote->{id}, 6, ' get_daily_quote returns the only existing quote' );
81
is( $quote->{id}, $quote_6->id, ' get_daily_quote returns the only existing quote' );
82
82
83
$schema->storage->txn_rollback;
83
$schema->storage->txn_rollback;
84
84
Lines 89-98 subtest "get_daily_quote_for_interface" => sub { Link Here
89
    $schema->storage->txn_begin;
89
    $schema->storage->txn_begin;
90
90
91
    my ($quote);
91
    my ($quote);
92
    my $quote_1 = Koha::Quote->new({ id => 10, source => 'Dusk And Her Embrace', text => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....', timestamp =>  dt_from_string })->store;
92
    my $quote_1 = Koha::Quote->new({ source => 'Dusk And Her Embrace', text => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....', timestamp =>  dt_from_string })->store;
93
93
94
    my $expected_quote = {
94
    my $expected_quote = {
95
        id          => 10,
95
        id          => $quote_1->id,
96
        source      => 'Dusk And Her Embrace',
96
        source      => 'Dusk And Her Embrace',
97
        text        => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....',
97
        text        => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....',
98
        timestamp   => DateTime::Format::MySQL->format_datetime(dt_from_string),
98
        timestamp   => DateTime::Format::MySQL->format_datetime(dt_from_string),
99
- 

Return to bug 16371