From df8fab4cf069cba700d841af2b780ebc36f52d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Thu, 8 Oct 2015 00:13:01 +0200 Subject: [PATCH] Bug 14977 - Remove C4::Dates from files t/db_dependent/*.t This patch removes C4::Dates from following files: - t/db_dependent/Budgets.t - t/db_dependent/Holds.t - t/db_dependent/Koha_template_plugin_KohaDates.t - t/db_dependent/Log.t - t/db_dependent/NewsChannels.t To test: - First run all tests above - Apply patch - Then run tests again. The results should be the same. (Note: I get 2 fails with NewsChannels.t, they are the same with and without patch). Signed-off-by: Bernardo Gonzalez Kriegel NewsChanell pass for me before patch, no after. Followup follows :) Rest of tests pass Signed-off-by: Jonathan Druart --- t/db_dependent/Budgets.t | 1 - t/db_dependent/Holds.t | 3 ++- t/db_dependent/Koha_template_plugin_KohaDates.t | 6 +----- t/db_dependent/Log.t | 8 ++++---- t/db_dependent/NewsChannels.t | 11 ++++++----- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t index 4e51ecd..5147002 100755 --- a/t/db_dependent/Budgets.t +++ b/t/db_dependent/Budgets.t @@ -8,7 +8,6 @@ use C4::Context; use C4::Biblio; use C4::Bookseller; use C4::Acquisition; -use C4::Dates; use C4::Members qw( AddMember ); use Koha::Acquisition::Order; diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 9a44084..203e715 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -133,8 +133,9 @@ ModReserve({ rank => '4', branchcode => $branch_1, itemnumber => $itemnumber, - suspend_until => C4::Dates->new("2013-01-01","iso")->output(), + suspend_until => output_pref( { dt => dt_from_string( "2013-01-01", "iso" ), dateonly => 1 } ), }); + $reserve = GetReserve( $reserve_id ); ok( $reserve->{'priority'} eq '4', "Test GetReserve(), priority changed correctly" ); ok( $reserve->{'suspend'}, "Test GetReserve(), suspend hold" ); diff --git a/t/db_dependent/Koha_template_plugin_KohaDates.t b/t/db_dependent/Koha_template_plugin_KohaDates.t index e45427e..d48e3c9 100644 --- a/t/db_dependent/Koha_template_plugin_KohaDates.t +++ b/t/db_dependent/Koha_template_plugin_KohaDates.t @@ -2,7 +2,7 @@ use Modern::Perl; use C4::Context; -use C4::Dates; +use Koha::DateUtils; use Test::More tests => 7; use Test::MockModule; @@ -14,14 +14,12 @@ my $module_context = new Test::MockModule('C4::Context'); my $date = "1973-05-21"; my $context = C4::Context->new(); -my $dateobj = C4::Dates->new(); my $filter = Koha::Template::Plugin::KohaDates->new(); ok ($filter, "new()"); $context->set_preference( "dateformat", 'iso' ); $context->clear_syspref_cache(); -$dateobj->reset_prefformat; my $filtered_date = $filter->filter($date); is ($filtered_date,$date, "iso conversion") or diag ("iso conversion fails"); @@ -29,14 +27,12 @@ is ($filtered_date,$date, "iso conversion") or diag ("iso conversion fails"); #$filter = Koha::Template::Plugin::KohaDates->new(); $context->set_preference( "dateformat", 'us' ); $context->clear_syspref_cache(); -$dateobj->reset_prefformat; $filtered_date = $filter->filter($date); is ($filtered_date,'05/21/1973', "us conversion") or diag ("us conversion fails $filtered_date"); $context->set_preference( "dateformat", 'metric' ); $context->clear_syspref_cache(); -$dateobj->reset_prefformat; $filtered_date = $filter->filter($date); is ($filtered_date,'21/05/1973', "metric conversion") or diag ("metric conversion fails $filtered_date"); diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t index cbd8937..e5ef418 100644 --- a/t/db_dependent/Log.t +++ b/t/db_dependent/Log.t @@ -8,9 +8,9 @@ use strict; use warnings; use Test::More tests => 7; -# We need C4::Dates to handle the dates -use C4::Dates; use C4::Context; +use Koha::DateUtils; + use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog use Data::Dumper; @@ -43,8 +43,8 @@ ok($success, "GetLogs returns results for an open search"); eval { # FIXME: US formatted date hardcoded into test for now - my $date = C4::Dates->new(); - $success = scalar(@{GetLogs($date->today(),$date->today(),"",undef,undef,"","")}); + my $date = output_pref( { dt => dt_from_string, datenonly => 1, dateformat => 'iso' } ); + $success = scalar(@{GetLogs( $date, $date, "", undef, undef, "", "") } ); } or do { diag($@); $success = 0; diff --git a/t/db_dependent/NewsChannels.t b/t/db_dependent/NewsChannels.t index 1928b46..fb32df5 100644 --- a/t/db_dependent/NewsChannels.t +++ b/t/db_dependent/NewsChannels.t @@ -1,8 +1,9 @@ #!/usr/bin/perl use Modern::Perl; -use C4::Dates qw(format_date); use C4::Branch qw(GetBranchName); +use Koha::DateUtils; + use Test::More tests => 12; BEGIN { @@ -122,10 +123,10 @@ $rv = upd_opac_new($href_entry2); ok( $rv == 1, 'Successfully updated second dummy news item!' ); # Test get_opac_new (single news item) -$timestamp1 = format_date($timestamp1); -$expirationdate1 = format_date($expirationdate1); -$timestamp2 = format_date($timestamp2); -$expirationdate2 = format_date($expirationdate2); +$timestamp1 = output_pref( { dt => dt_from_string( $timestamp1 ), dateonly => 1, dateformat => 'iso' } ); +$expirationdate1 = output_pref( { dt => dt_from_string( $expirationdate1 ), dateonly => 1, dateformat => 'iso' } ); +$timestamp2 = output_pref( { dt => dt_from_string( $timestamp2 ), dateonly => 1, dateformat => 'iso' } ); +$expirationdate2 = output_pref( { dt => dt_from_string( $expirationdate2) , dateonly => 1, dateformat => 'iso' } ); is_deeply( get_opac_new($idnew1), -- 2.1.0