From fa1ac76dc0f45911e459c6c8138e05c32bf32231 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 12 Aug 2020 09:16:43 +0300 Subject: [PATCH 1/2] Bug 16371: Remove GetDailyQuote tests from Koha.t Tests in Koha.t failed due GetDailyQuote tests. This patch removes these tests since we test quotes in Quotes.t instead. To test prove t/db_dependent/Koha.t Sponsored-by: Koha-Suomi Oy --- t/db_dependent/Koha.t | 63 ++----------------------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index e21687830f..9e0b8d3af9 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -4,19 +4,17 @@ # It requires a working Koha database with the sample data use Modern::Perl; -use DateTime::Format::MySQL; -use Test::More tests => 6; +use Test::More tests => 5; use t::lib::TestBuilder; use C4::Context; use Koha::Database; -use Koha::DateUtils qw(dt_from_string); use Koha::AuthorisedValue; use Koha::AuthorisedValueCategories; BEGIN { - use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized)); + use_ok('C4::Koha', qw( :DEFAULT GetItemTypesCategorized)); use_ok('C4::Members'); } @@ -157,63 +155,6 @@ subtest 'Authorized Values Tests' => sub { }; -### test for C4::Koha->GetDailyQuote() -SKIP: - { - eval { require Test::Deep; import Test::Deep; }; - skip "Test::Deep required to run the GetDailyQuote tests.", 1 if $@; - - subtest 'Daily Quotes Test' => sub { - plan tests => 4; - - SKIP: { - - skip "C4::Koha can't \'GetDailyQuote\'!", 3 unless can_ok('C4::Koha','GetDailyQuote'); - -# Fill the quote table with the default needed and a spare -$dbh->do("DELETE FROM quotes WHERE id=3 OR id=25;"); -my $sql = "INSERT INTO quotes (id,source,text,timestamp) VALUES -(25,'Richard Nixon','When the President does it, that means that it is not illegal.',NOW()), -(3,'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());"; -$dbh->do($sql); - - my $expected_quote = { - id => 3, - 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 => re('\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}'), #'YYYY-MM-DD HH:MM:SS' - }; - -# test quote retrieval based on id - - my $quote = GetDailyQuote('id'=>3); - cmp_deeply ($quote, $expected_quote, "Got a quote based on id.") or - diag('Be sure to run this test on a clean install of sample data.'); - -# test quote retrieval based on today's date - - my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; - my $sth = C4::Context->dbh->prepare($query); - $sth->execute(DateTime::Format::MySQL->format_datetime( dt_from_string() ), $expected_quote->{'id'}); - - DateTime::Format::MySQL->format_datetime( dt_from_string() ) =~ m/(\d{4}-\d{2}-\d{2})/; - $expected_quote->{'timestamp'} = re("^$1"); - -# $expected_quote->{'timestamp'} = DateTime::Format::MySQL->format_datetime( dt_from_string() ); # update the timestamp of expected quote data - - $quote = GetDailyQuote(); # this is the "default" mode of selection - cmp_deeply ($quote, $expected_quote, "Got a quote based on today's date.") or - diag('Be sure to run this test on a clean install of sample data.'); - -# test random quote retrieval - - $quote = GetDailyQuote('random'=>1); - ok ($quote, "Got a random quote."); - } - }; -} - - subtest 'ISBN tests' => sub { plan tests => 6; -- 2.17.1