Bugzilla – Attachment 23668 Details for
Bug 11279
Quote of the day feature won't pick a quote
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11279: regression test for picking random quote
Bug-11279-regression-test-for-picking-random-quote.patch (text/plain), 3.64 KB, created by
Jonathan Druart
on 2013-12-19 10:25:15 UTC
(
hide
)
Description:
Bug 11279: regression test for picking random quote
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-12-19 10:25:15 UTC
Size:
3.64 KB
patch
obsolete
>From 0b1d79fbf8540a543420e1811ed448f400cc42ce Mon Sep 17 00:00:00 2001 >From: Katrin Fischer <Katrin.Fischer.83@web.de> >Date: Thu, 12 Dec 2013 20:50:52 +0100 >Subject: [PATCH] Bug 11279: regression test for picking random quote > >This patch adds new tests based on the db_dependent tests in >t/db_dependent/Koha.t for GetDailyQuote(). > >Tests run on an empty database and don't require Test::Deep. > >Tests will fail before applying the patch for 11297, but will >pass after applying the patch. > >Signed-off-by: Galen Charlton <gmc@esilibrary.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > t/db_dependent/Koha/GetDailyQuote.t | 67 +++++++++++++++++++++++++++++++++++ > 1 file changed, 67 insertions(+) > create mode 100644 t/db_dependent/Koha/GetDailyQuote.t > >diff --git a/t/db_dependent/Koha/GetDailyQuote.t b/t/db_dependent/Koha/GetDailyQuote.t >new file mode 100644 >index 0000000..2785b22 >--- /dev/null >+++ b/t/db_dependent/Koha/GetDailyQuote.t >@@ -0,0 +1,67 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 9; >+use C4::Koha qw( GetDailyQuote ); >+use DateTime::Format::MySQL; >+use Koha::DateUtils qw(dt_from_string); >+ >+BEGIN { >+ use_ok('C4::Koha'); >+} >+ >+can_ok('C4::Koha', qw( GetDailyQuote )); >+ >+my $dbh = C4::Context->dbh; >+ >+# Start transaction >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+# Setup stage >+$dbh->do("DELETE FROM quotes"); >+ >+# Ids not starting with 1 to reflect possible deletes, this acts as a regression test for bug 11297 >+$dbh->do("INSERT INTO `quotes` VALUES >+(6,'George Washington','To be prepared for war is one of the most effectual means of preserving peace.','0000-00-00 00:00:00'), >+(7,'Thomas Jefferson','When angry, count ten, before you speak; if very angry, an hundred.','0000-00-00 00:00:00'), >+(8,'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.','0000-00-00 00:00:00'), >+(9,'Abraham Lincoln','I have always found that mercy bears richer fruits than strict justice.','0000-00-00 00:00:00'), >+(10,'Andrew Johnson','I feel incompetent to perform duties...which have been so unexpectedly thrown upon me.','0000-00-00 00:00:00');"); >+ >+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 => '0000-00-00 00:00:00', >+}; >+ >+diag("Get a quote based on id"); >+my $quote = GetDailyQuote('id'=>8); >+cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Id is correct"); >+is($quote->{'quote'}, $expected_quote->{'quote'}, "Quote is correct"); >+ >+ >+diag("Get a random quote"); >+$quote = GetDailyQuote('random'=>1); >+ok($quote, "Got a random quote."); >+cmp_ok($quote->{'id'}, '>', 0, 'Id is greater than 0'); >+ >+ >+diag("Get a quote based on today's date"); >+$dbh->do("UPDATE quotes SET timestamp = '0000-00-00 00:00:00';"); >+my $timestamp = DateTime::Format::MySQL->format_datetime(dt_from_string()); >+my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; >+my $sth = C4::Context->dbh->prepare($query); >+$sth->execute( $timestamp , $expected_quote->{'id'}); >+ >+$expected_quote->{'timestamp'} = $timestamp; >+ >+$quote = GetDailyQuote(); # this is the "default" mode of selection >+cmp_ok($quote->{'id'}, '==', $expected_quote->{'id'}, "Id is correct"); >+is($quote->{'quote'}, $expected_quote->{'quote'}, "Quote is correct"); >+is($quote->{'timestamp'}, $expected_quote->{'timestamp'}, "Timestamp $timestamp is correct"); >+ >+ >+$dbh->rollback; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11279
:
23493
|
23494
|
23662
|
23663
| 23668 |
23669
|
23670