Bugzilla – Attachment 40686 Details for
Bug 6810
Send membership expiry reminder notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6810 - Fix QA failures
0003-Bug-6810-Fix-QA-failures.patch (text/plain), 6.22 KB, created by
Amit Gupta
on 2015-06-26 17:43:52 UTC
(
hide
)
Description:
Bug 6810 - Fix QA failures
Filename:
MIME Type:
Creator:
Amit Gupta
Created:
2015-06-26 17:43:52 UTC
Size:
6.22 KB
patch
obsolete
>From dd2daebf21b1dd012c7fceae557a9b6bf7199298 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Fri, 12 Jun 2015 12:08:41 +0200 >Subject: [PATCH 3/7] Bug 6810 - Fix QA failures > >- Use KohaDates to convert dateexpiry >- remove MYSQL specifics methods for date handling in > GetUpcomingMembershipExpires >- make the script membership_expiry.pl write in Koha system logs >- add tests > >Signed-off-by: Indranil Das Gupta (L2C2 Technologies) <indradg@gmail.com> >--- > C4/Letters.pm | 13 ++--- > C4/Members.pm | 6 ++- > misc/cronjobs/membership_expiry.pl | 3 ++ > t/Members.t | 105 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 116 insertions(+), 11 deletions(-) > create mode 100644 t/Members.t > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 16f5d11..18b8464 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -35,6 +35,7 @@ use Date::Calc qw( Add_Delta_Days ); > use Encode; > use Carp; > use Koha::Email; >+use Koha::Template::Plugin::KohaDates; > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -786,15 +787,9 @@ sub _parseletter { > my ( $letter, $table, $values ) = @_; > > if ( $table eq 'borrowers' && $values->{'dateexpiry'} ){ >- my @dateexpiry = split /-/, $values->{'dateexpiry'}; >- >- $values->{'dateexpiry'} = C4::Dates->new( >- sprintf( >- '%04d-%02d-%02d', >- Add_Delta_Days( @dateexpiry,0) >- ), >- 'iso' >- )->output(); >+ $values->{'dateexpiry'} = Koha::Template::Plugin::KohaDates >+ ->new() >+ ->filter($values->{'dateexpiry'}); > } > > if ( $table eq 'reserves' && $values->{'waitingdate'} ) { >diff --git a/C4/Members.pm b/C4/Members.pm >index 9c9bfa7..f03134b 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -1490,15 +1490,17 @@ sub GetExpiryDate { > sub GetUpcomingMembershipExpires { > my $dbh = C4::Context->dbh; > my $days = C4::Context->preference("MembershipExpiryDaysNotice"); >+ my $dateexpiry = DateTime->now()->add(days => $days)->ymd(); >+ > my $query = " > SELECT borrowers.*, categories.description, > branches.branchname, branches.branchemail FROM borrowers > LEFT JOIN branches on borrowers.branchcode = branches.branchcode > LEFT JOIN categories on borrowers.categorycode = categories.categorycode >- WHERE dateexpiry = DATE_ADD(CURDATE(),INTERVAL $days DAY); >+ WHERE dateexpiry = ?; > "; > my $sth = $dbh->prepare($query); >- $sth->execute; >+ $sth->execute($dateexpiry); > my $results = $sth->fetchall_arrayref({}); > return $results; > } >diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl >index 2ed3d75..f92b77f 100755 >--- a/misc/cronjobs/membership_expiry.pl >+++ b/misc/cronjobs/membership_expiry.pl >@@ -45,6 +45,9 @@ BEGIN { > use C4::Context; > use C4::Letters; > use C4::Dates qw/format_date/; >+use C4::Log; >+ >+cronlogaction(); > > # These are defaults for command line options. > my $confirm; # -c: Confirm that the user has read and configured this script. >diff --git a/t/Members.t b/t/Members.t >new file mode 100644 >index 0000000..c040238 >--- /dev/null >+++ b/t/Members.t >@@ -0,0 +1,105 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2015 Biblibre >+# >+# 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 C4::Members; >+use Test::MockModule; >+use t::lib::TestBuilder; >+use t::lib::Mocks qw( mock_preference ); >+ >+use Test::More tests => 3; >+use Test::MockModule; >+ >+BEGIN { >+ use_ok('C4::Members'); >+} >+ >+my $date_time = new Test::MockModule('DateTime'); >+$date_time->mock( >+ 'now', sub { >+ return DateTime->new( >+ year => 2015, >+ month => 6, >+ day => 15, >+ ); >+ >+}); >+ >+t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 15); >+ >+my $builder = t::lib::TestBuilder->new(); >+$builder->build({ >+ source => 'Category', >+ value => { >+ categorycode => 'AD', >+ description => 'Adult', >+ enrolmentperiod => 18, >+ upperagelimit => 99, >+ category_type => 'A', >+ }, >+}); >+ >+$builder->build({ >+ source => 'Branch', >+ value => { >+ branchcode => 'CR', >+ branchname => 'My branch', >+ }, >+}); >+ >+$builder->build({ >+ source => 'Borrower', >+ value => { >+ firstname => 'Vincent', >+ surname => 'Martin', >+ cardnumber => '80808081', >+ categorycode => 'AD', >+ branchcode => 'CR', >+ dateexpiry => '2015-06-30' >+ }, >+}); >+ >+$builder->build({ >+ source => 'Borrower', >+ value => { >+ firstname => 'Claude', >+ surname => 'Dupont', >+ cardnumber => '80808082', >+ categorycode => 'AD', >+ branchcode => 'CR', >+ dateexpiry => '2015-06-29' >+ }, >+}); >+ >+$builder->build({ >+ source => 'Borrower', >+ value => { >+ firstname => 'Gilles', >+ surname => 'Dupond', >+ cardnumber => '80808083', >+ categorycode => 'AD', >+ branchcode => 'CR', >+ dateexpiry => '2015-07-02' >+ }, >+}); >+ >+my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires(); >+is(scalar(@$upcoming_mem_expires), 1, 'Get upcoming membership expires should return 1 borrower.'); >+ >+is($upcoming_mem_expires->[0]{surname}, 'Martin', 'Get upcoming membership expires should return borrower "Martin".'); >-- >1.7.9.5 >
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 6810
:
5375
|
9751
|
21870
|
21871
|
21872
|
22459
|
32683
|
32684
|
32689
|
32692
|
33954
|
40090
|
40091
|
40100
|
40120
|
40121
|
40122
|
40179
|
40180
|
40641
|
40642
|
40643
|
40644
|
40645
|
40646
|
40649
|
40665
|
40666
|
40667
|
40685
|
40686
|
40687
|
40688
|
40689
|
40690
|
40700
|
40701
|
40766
|
41916
|
42609
|
42610
|
42611
|
42612
|
42613
|
42700