Bug 16371: Rename test file
authorEmmi Takkinen <emmi.takkinen@outlook.com>
Mon, 20 Apr 2020 12:20:18 +0000 (15:20 +0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 13 Aug 2020 08:15:33 +0000 (10:15 +0200)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Koha/GetDailyQuote.t [deleted file]
t/db_dependent/Koha/Quotes.t [new file with mode: 0644]

diff --git a/t/db_dependent/Koha/GetDailyQuote.t b/t/db_dependent/Koha/GetDailyQuote.t
deleted file mode 100644 (file)
index d4c979b..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/perl
-
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# Koha is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Koha; if not, see <http://www.gnu.org/licenses>.
-
-use Modern::Perl;
-use DateTime::Format::MySQL;
-use Test::More tests => 12;
-
-use Koha::Database;
-use Koha::DateUtils qw(dt_from_string);
-use Koha::Quote;
-use Koha::Quotes;
-
-BEGIN {
-    use_ok('Koha::Quote');
-}
-
-my $quote = Koha::Quote->new();
-isa_ok( $quote, 'Koha::Quote', 'Quote class returned' );
-
-my $schema = Koha::Database->new->schema;
-$schema->storage->txn_begin;
-my $dbh = C4::Context->dbh;
-
-# Ids not starting with 1 to reflect possible deletes, this acts as a regression test for bug 11297
-my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string()); #???
-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;
-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;
-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;
-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;
-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;
-
-my $expected_quote = {
-    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   => dt_from_string,
-};
-
-$quote = Koha::Quote->get_daily_quote('id'=>$quote_3->id);
-cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Correctly got quote by ID");
-is($quote->{'quote'}, $expected_quote->{'quote'}, "Quote is correct");
-
-$quote = Koha::Quote->get_daily_quote('random'=>1);
-ok($quote, "Got a random quote.");
-cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0');
-
-$timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string->add( seconds => 1 )); # To make it the last one
-Koha::Quotes->search({ id => $expected_quote->{'id'} })->update({ timestamp => $timestamp });
-$expected_quote->{'timestamp'} = $timestamp;
-
-$quote = Koha::Quote->get_daily_quote(); # this is the "default" mode of selection
-cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Id is correct");
-is($quote->{'source'}, $expected_quote->{'source'}, "Source is correct");
-is($quote->{'timestamp'}, $expected_quote->{'timestamp'}, "Timestamp $timestamp is correct");
-
-$dbh->do(q|DELETE FROM quotes|);
-$quote = eval {Koha::Quote->get_daily_quote();};
-is( $@, '', 'get_daily_quote does not die if no quote exist' );
-is_deeply( $quote, {}, 'get_daily_quote return an empty hashref is no quote exist'); # Is it what we expect?
-
-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;
-
-$quote = Koha::Quote->get_daily_quote();
-is( $quote->{id}, 6, ' get_daily_quote returns the only existing quote' );
diff --git a/t/db_dependent/Koha/Quotes.t b/t/db_dependent/Koha/Quotes.t
new file mode 100644 (file)
index 0000000..d4c979b
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+use DateTime::Format::MySQL;
+use Test::More tests => 12;
+
+use Koha::Database;
+use Koha::DateUtils qw(dt_from_string);
+use Koha::Quote;
+use Koha::Quotes;
+
+BEGIN {
+    use_ok('Koha::Quote');
+}
+
+my $quote = Koha::Quote->new();
+isa_ok( $quote, 'Koha::Quote', 'Quote class returned' );
+
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+my $dbh = C4::Context->dbh;
+
+# Ids not starting with 1 to reflect possible deletes, this acts as a regression test for bug 11297
+my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string()); #???
+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;
+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;
+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;
+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;
+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;
+
+my $expected_quote = {
+    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   => dt_from_string,
+};
+
+$quote = Koha::Quote->get_daily_quote('id'=>$quote_3->id);
+cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Correctly got quote by ID");
+is($quote->{'quote'}, $expected_quote->{'quote'}, "Quote is correct");
+
+$quote = Koha::Quote->get_daily_quote('random'=>1);
+ok($quote, "Got a random quote.");
+cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0');
+
+$timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string->add( seconds => 1 )); # To make it the last one
+Koha::Quotes->search({ id => $expected_quote->{'id'} })->update({ timestamp => $timestamp });
+$expected_quote->{'timestamp'} = $timestamp;
+
+$quote = Koha::Quote->get_daily_quote(); # this is the "default" mode of selection
+cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Id is correct");
+is($quote->{'source'}, $expected_quote->{'source'}, "Source is correct");
+is($quote->{'timestamp'}, $expected_quote->{'timestamp'}, "Timestamp $timestamp is correct");
+
+$dbh->do(q|DELETE FROM quotes|);
+$quote = eval {Koha::Quote->get_daily_quote();};
+is( $@, '', 'get_daily_quote does not die if no quote exist' );
+is_deeply( $quote, {}, 'get_daily_quote return an empty hashref is no quote exist'); # Is it what we expect?
+
+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;
+
+$quote = Koha::Quote->get_daily_quote();
+is( $quote->{id}, 6, ' get_daily_quote returns the only existing quote' );