Lines 17-29
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use DateTime::Format::MySQL; |
19 |
use DateTime::Format::MySQL; |
20 |
use Test::More tests => 12; |
20 |
use Test::More tests => 13; |
21 |
|
21 |
|
22 |
use Koha::Database; |
22 |
use Koha::Database; |
23 |
use Koha::DateUtils qw(dt_from_string); |
23 |
use Koha::DateUtils qw(dt_from_string); |
24 |
use Koha::Quote; |
24 |
use Koha::Quote; |
25 |
use Koha::Quotes; |
25 |
use Koha::Quotes; |
26 |
|
26 |
|
|
|
27 |
use t::lib::TestBuilder; |
28 |
use t::lib::Mocks; |
29 |
|
27 |
BEGIN { |
30 |
BEGIN { |
28 |
use_ok('Koha::Quote'); |
31 |
use_ok('Koha::Quote'); |
29 |
} |
32 |
} |
Lines 76-78
my $quote_6 = Koha::Quote->new({ id => 6, source => 'George Washington', text =>
Link Here
|
76 |
|
79 |
|
77 |
$quote = Koha::Quote->get_daily_quote(); |
80 |
$quote = Koha::Quote->get_daily_quote(); |
78 |
is( $quote->{id}, 6, ' get_daily_quote returns the only existing quote' ); |
81 |
is( $quote->{id}, 6, ' get_daily_quote returns the only existing quote' ); |
79 |
- |
82 |
|
|
|
83 |
$schema->storage->txn_rollback; |
84 |
|
85 |
subtest "get_daily_quote_for_interface" => sub { |
86 |
|
87 |
plan tests => 3; |
88 |
|
89 |
$schema->storage->txn_begin; |
90 |
|
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; |
93 |
|
94 |
my $expected_quote = { |
95 |
id => 10, |
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....', |
98 |
timestamp => DateTime::Format::MySQL->format_datetime(dt_from_string), |
99 |
}; |
100 |
|
101 |
t::lib::Mocks::mock_preference('QuoteOfTheDay', ''); |
102 |
|
103 |
##Set interface and get nothing because syspref is not set. |
104 |
C4::Context->interface('opac'); |
105 |
$quote = Koha::Quote->get_daily_quote_for_interface(id => $quote_1->id); |
106 |
ok(not($quote), "'QuoteOfTheDay'-syspref not set so nothing returned"); |
107 |
|
108 |
##Set 'QuoteOfTheDay'-syspref to not include current interface 'opac' |
109 |
t::lib::Mocks::mock_preference('QuoteOfTheDay', 'intra commandline sip2 api yo-mama'); |
110 |
$quote = Koha::Quote->get_daily_quote_for_interface(id => $quote_1->id); |
111 |
ok(not($quote), "'QuoteOfTheDay'-syspref doesn't include 'opac'"); |
112 |
|
113 |
##Set 'QuoteOfTheDay'-syspref to include current interface 'opac' |
114 |
t::lib::Mocks::mock_preference('QuoteOfTheDay', 'intraopaccommandline'); |
115 |
$quote = Koha::Quote->get_daily_quote_for_interface(id => $quote_1->id); |
116 |
is_deeply($quote, $expected_quote, "Got the expected quote"); |
117 |
|
118 |
$schema->storage->txn_rollback; |
119 |
}; |