Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
use Test::More; |
5 |
use Test::More tests => 1; |
6 |
use Try::Tiny; |
7 |
|
8 |
use C4::Koha; |
9 |
|
10 |
my $dbh = C4::Context->dbh; |
11 |
|
12 |
# Start transaction |
13 |
$dbh->{RaiseError} = 1; |
14 |
# Setup stage |
15 |
$dbh->do("DELETE FROM quotes"); |
16 |
##populate test context |
17 |
$dbh->do("INSERT INTO `quotes` VALUES |
18 |
(10,'Dusk And Her Embrace','Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....','0000-00-00 00:00:00'); |
19 |
"); |
20 |
|
21 |
my $expected_quote = { |
22 |
id => 10, |
23 |
source => 'Dusk And Her Embrace', |
24 |
text => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....', |
25 |
timestamp => '0000-00-00 00:00:00', |
26 |
}; |
27 |
|
28 |
|
29 |
subtest "GetDailyQuoteForInterface", \&GetDailyQuoteForInterfaceTest; |
30 |
sub GetDailyQuoteForInterfaceTest { |
31 |
my ($quote); |
32 |
|
33 |
##Set interface and get nothing because syspref is not set. |
34 |
C4::Context->interface('opac'); |
35 |
$quote = C4::Koha::GetDailyQuoteForInterface(id => 10); |
36 |
ok(not($quote), "'QuoteOfTheDay'-syspref not set so nothing returned"); |
37 |
|
38 |
##Set 'QuoteOfTheDay'-syspref to not include current interface 'opac' |
39 |
C4::Context->set_preference('QuoteOfTheDay', 'intra commandline sip2 api yo-mama'); |
40 |
$quote = C4::Koha::GetDailyQuoteForInterface(id => 10); |
41 |
ok(not($quote), "'QuoteOfTheDay'-syspref doesn't include 'opac'"); |
42 |
|
43 |
##Set 'QuoteOfTheDay'-syspref to include current interface 'opac' |
44 |
C4::Context->set_preference('QuoteOfTheDay', 'intraopaccommandline'); |
45 |
$quote = C4::Koha::GetDailyQuoteForInterface(id => 10); |
46 |
is_deeply($quote, $expected_quote, "Got the expected quote"); |
47 |
|
48 |
} |
49 |
|
50 |
# teardown |
51 |
C4::Context->set_preference('QuoteOfTheDay', undef); |
52 |
$dbh->do("DELETE FROM quotes"); |