|
Lines 1-8
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
|
|
3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Koha is free software; you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Koha is distributed in the hope that it will be useful, but |
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 17 |
|
| 3 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 4 |
|
19 |
|
| 5 |
use Test::More tests => 12; |
20 |
use Test::More tests => 12; |
|
|
21 |
|
| 6 |
use C4::Koha qw( GetDailyQuote ); |
22 |
use C4::Koha qw( GetDailyQuote ); |
| 7 |
use DateTime::Format::MySQL; |
23 |
use DateTime::Format::MySQL; |
| 8 |
use Koha::DateUtils qw(dt_from_string); |
24 |
use Koha::DateUtils qw(dt_from_string); |
|
Lines 37-55
my $expected_quote = {
Link Here
|
| 37 |
timestamp => '0000-00-00 00:00:00', |
53 |
timestamp => '0000-00-00 00:00:00', |
| 38 |
}; |
54 |
}; |
| 39 |
|
55 |
|
| 40 |
diag("Get a quote based on id"); |
|
|
| 41 |
my $quote = GetDailyQuote('id'=>8); |
56 |
my $quote = GetDailyQuote('id'=>8); |
| 42 |
cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Id is correct"); |
57 |
cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Correctly got quote by ID"); |
| 43 |
is($quote->{'quote'}, $expected_quote->{'quote'}, "Quote is correct"); |
58 |
is($quote->{'quote'}, $expected_quote->{'quote'}, "Quote is correct"); |
| 44 |
|
59 |
|
| 45 |
|
|
|
| 46 |
diag("Get a random quote"); |
| 47 |
$quote = GetDailyQuote('random'=>1); |
60 |
$quote = GetDailyQuote('random'=>1); |
| 48 |
ok($quote, "Got a random quote."); |
61 |
ok($quote, "Got a random quote."); |
| 49 |
cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0'); |
62 |
cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0'); |
| 50 |
|
63 |
|
| 51 |
|
|
|
| 52 |
diag("Get a quote based on today's date"); |
| 53 |
$dbh->do("UPDATE quotes SET timestamp = '0000-00-00 00:00:00';"); |
64 |
$dbh->do("UPDATE quotes SET timestamp = '0000-00-00 00:00:00';"); |
| 54 |
my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string()); |
65 |
my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string()); |
| 55 |
my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; |
66 |
my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; |
| 56 |
- |
|
|