From 8f17e44795c09a69ea3c946301d7873b3cada34a Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Wed, 31 Jul 2013 11:39:45 +0200 Subject: [PATCH] Bug 10666 - Daily quotes tests are failing In t/db_dependent/Koha.t, the test "Got a quote based on today's date" is failing : $prove t/db_dependent/Koha.t : t/db_dependent/Koha.t .. 1/6 # Failed test 'Got a quote based on today's date.' # at t/db_dependent/Koha.t line 126. # Compared $data->{"source"} # got : 'Herbert Hoover' # expect : 'Abraham Lincoln' # Be sure to run this test on a clean install of sample data. # Looks like you failed 1 test of 4. Looks like the wrong quote is returned by GetDailyQuote(). I'm using a databased created with the English sample SQL datas. I think I found the cause : The test "Got a random quote." calls GetDailyQuote('random'=>1) which changes the quote timestamp to now. When then testing GetDailyQuote(), this quote (which may not be the one created by test) is the most recent quote. This patch moves the "Got a random quote." test after "Got a quote based on today's date" to solve the problem. --- t/db_dependent/Koha.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index 1a68c7d..500315f 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -106,11 +106,6 @@ SKIP: 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 random quote retrieval - - $quote = GetDailyQuote('random'=>1); - ok ($quote, "Got a random quote."); - # test quote retrieval based on today's date my $query = 'UPDATE quotes SET timestamp = ? WHERE id = ?'; @@ -125,6 +120,11 @@ SKIP: $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."); } }; } -- 1.7.10.4