Bug 15548: Move new patron related code to Patron*

The 'borrower' should not be used anymore, especially for new code.
This patch move files and rename variables newly pushed (i.e. in the Koha
namespace).

Test plan:
1/
  git grep Koha::Borrower
should not return code in use.

2/
Prove the different modified test files

3/ Do some clicks in the member^Wpatron module to be sure there is not
an obvious error.

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as described. Tested with Circulation, Members/Patrons, Discharge,
Restrictions modules and the must common functionalities

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-01-11 15:57:59 +00:00 committed by Jesse Weaver
parent d53daa3392
commit 3691bd8419
56 changed files with 563 additions and 563 deletions

View File

@ -48,8 +48,8 @@ use Data::Dumper;
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Items;
use Koha::Borrowers;
use Koha::Borrower::Debarments;
use Koha::Patrons;
use Koha::Patron::Debarments;
use Koha::Database;
use Koha::Libraries;
use Carp;
@ -2201,7 +2201,7 @@ sub MarkIssueReturned {
if ( C4::Context->preference('StoreLastBorrower') ) {
my $item = Koha::Items->find( $itemnumber );
my $patron = Koha::Borrowers->find( $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
$item->last_returned_by( $patron );
}
}
@ -2265,13 +2265,13 @@ sub _debar_user_on_return {
my $new_debar_dt =
$dt_today->clone()->add_duration( $suspension_days );
Koha::Borrower::Debarments::AddUniqueDebarment({
Koha::Patron::Debarments::AddUniqueDebarment({
borrowernumber => $borrower->{borrowernumber},
expiration => $new_debar_dt->ymd(),
type => 'SUSPENSION',
});
# if borrower was already debarred but does not get an extra debarment
if ( $borrower->{debarred} eq Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber}) ) {
if ( $borrower->{debarred} eq Koha::Patron::Debarments::IsDebarred($borrower->{borrowernumber}) ) {
return ($borrower->{debarred},1);
}
return $new_debar_dt->ymd();
@ -2834,7 +2834,7 @@ sub CanBookBeRenewed {
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
my $restricted = Koha::Patron::Debarments::IsDebarred($borrowernumber);
my $hasoverdues = C4::Members::HasOverdues($borrowernumber);
if ( $restricted and $restrictionblockrenewing ) {

View File

@ -36,7 +36,7 @@ use C4::NewsChannels; #get slip news
use DateTime;
use Koha::Database;
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Patron::Debarments qw(IsDebarred);
use Text::Unaccent qw( unac_string );
use Koha::AuthUtils qw(hash_password);
use Koha::Database;
@ -516,7 +516,7 @@ sub IsMemberBlocked {
my $borrowernumber = shift;
my $dbh = C4::Context->dbh;
my $blockeddate = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
my $blockeddate = Koha::Patron::Debarments::IsDebarred($borrowernumber);
return ( 1, $blockeddate ) if $blockeddate;

View File

@ -24,7 +24,7 @@ use Carp;
use C4::Context qw(preference);
use Koha::DateUtils qw(dt_from_string);
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Biblios;
use Koha::Items;
use Koha::Libraries;
@ -223,14 +223,14 @@ sub branch {
=head3 borrower
Returns the related Koha::Borrower object for this Hold
Returns the related Koha::Patron object for this Hold
=cut
sub borrower {
my ($self) = @_;
$self->{_borrower} ||= Koha::Borrowers->find( $self->borrowernumber() );
$self->{_borrower} ||= Koha::Patrons->find( $self->borrowernumber() );
return $self->{_borrower};
}

View File

@ -23,7 +23,7 @@ use Carp;
use Koha::Database;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Libraries;
use base qw(Koha::Object);
@ -78,7 +78,7 @@ sub holding_branch {
Gets and sets the last borrower to return an item.
Accepts and returns Koha::Borrower objects
Accepts and returns Koha::Patron objects
$item->last_returned_by( $borrowernumber );
@ -99,7 +99,7 @@ sub last_returned_by {
unless ( $self->{_last_returned_by} ) {
my $result = $items_last_returned_by_rs->single( { itemnumber => $self->id } );
if ($result) {
$self->{_last_returned_by} = Koha::Borrowers->find( $result->get_column('borrowernumber') );
$self->{_last_returned_by} = Koha::Patrons->find( $result->get_column('borrowernumber') );
}
}

View File

@ -255,7 +255,7 @@ __END__
=head1 SEE ALSO
Koha::Borrower::Files
Koha::Patron::Files
=head1 AUTHOR

View File

@ -1,4 +1,4 @@
package Koha::Borrower;
package Koha::Patron;
# Copyright ByWater Solutions 2014
#
@ -27,7 +27,7 @@ use base qw(Koha::Object);
=head1 NAME
Koha::Borrower - Koha Borrower Object class
Koha::Patron - Koha Patron Object class
=head1 API
@ -37,14 +37,14 @@ Koha::Borrower - Koha Borrower Object class
=head3 guarantor
Returns a Koha::Borrower object for this borrower's guarantor
Returns a Koha::Patron object for this patron's guarantor
=cut
sub guarantor {
my ( $self ) = @_;
return Koha::Borrowers->find( $self->guarantorid() );
return Koha::Patrons->find( $self->guarantorid() );
}
=head3 type

View File

@ -1,4 +1,4 @@
package Koha::Borrower::Debarments;
package Koha::Patron::Debarments;
# This file is part of Koha.
#
@ -36,9 +36,9 @@ our @EXPORT = qw(
IsDebarred
);
=head1 Koha::Borrower::Debarments
=head1 Koha::Patron::Debarments
Koha::Borrower::Debarments - Module for managing borrower debarments
Koha::Patron::Debarments - Module for managing patron debarments
=cut
@ -174,7 +174,7 @@ sub ModDebarment {
my $debarment_expiration = IsDebarred( $borrowernumber );
Returns the date a borrowers debarment will expire, or
undef if the borrower is not debarred
undef if the patron is not debarred
=cut

View File

@ -1,4 +1,4 @@
package Koha::Borrower::Discharge;
package Koha::Patron::Discharge;
use Modern::Perl;
use CGI;
@ -51,7 +51,7 @@ sub is_discharged {
my $borrowernumber = $params->{borrowernumber};
my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber);
my $restricted = Koha::Patron::Debarments::IsDebarred($borrowernumber);
my $validated = get_validated({borrowernumber => $borrowernumber});
if ($restricted && $validated) {
@ -85,7 +85,7 @@ sub discharge {
}
# Debar the member
Koha::Borrower::Debarments::AddDebarment({
Koha::Patron::Debarments::AddDebarment({
borrowernumber => $borrowernumber,
type => 'DISCHARGE',
});

View File

@ -1,4 +1,4 @@
package Koha::Borrower::Files;
package Koha::Patron::Files;
# Copyright 2012 Kyle M Hall
#
@ -33,7 +33,7 @@ BEGIN {
=head1 NAME
Koha::Borrower::Files - Module for managing borrower files
Koha::Patron::Files - Module for managing patron files
=head1 METHODS
@ -52,7 +52,7 @@ sub new {
=item GetFilesInfo()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
my $files_hashref = $bf->GetFilesInfo
=cut
@ -79,7 +79,7 @@ sub GetFilesInfo {
=item AddFile()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
$bh->AddFile( name => $filename, type => $mimetype,
description => $description, content => $content );
@ -107,7 +107,7 @@ sub AddFile {
=item GetFile()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
my $file = $bh->GetFile( file_id => $file_id );
=cut
@ -128,7 +128,7 @@ sub GetFile {
=item DelFile()
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
$bh->DelFile( file_id => $file_id );
=cut

View File

@ -1,4 +1,4 @@
package Koha::Borrower::Modifications;
package Koha::Patron::Modifications;
# Copyright 2012 ByWater Solutions
# This file is part of Koha.
@ -18,7 +18,7 @@ package Koha::Borrower::Modifications;
=head1 NAME
C4::Borrowers::Modifications
Koha::Patron::Modifications
=cut
@ -35,9 +35,9 @@ sub new {
=head2 AddModifications
Koha::Borrower::Modifications->AddModifications( $data );
Koha::Patron::Modifications->AddModifications( $data );
Adds or updates modifications for a borrower.
Adds or updates modifications for a patron
Requires either the key borrowernumber, or verification_token
to be part of the passed in hash.
@ -67,7 +67,7 @@ sub AddModifications {
=head2 Verify
$verified = Koha::Borrower::Modifications->Verify( $verification_token );
$verified = Koha::Patron::Modifications->Verify( $verification_token );
Returns true if the passed in token is valid.
@ -96,9 +96,9 @@ sub Verify {
=head2 GetPendingModificationsCount
$count = Koha::Borrower::Modifications->GetPendingModificationsCount();
$count = Koha::Patron::Modifications->GetPendingModificationsCount();
Returns the number of pending modifications for existing borrowers.
Returns the number of pending modifications for existing patron.
=cut
@ -128,9 +128,9 @@ sub GetPendingModificationsCount {
=head2 GetPendingModifications
$arrayref = Koha::Borrower::Modifications->GetPendingModifications();
$arrayref = Koha::Patron::Modifications->GetPendingModifications();
Returns an arrayref of hashrefs for all pending modifications for existing borrowers.
Returns an arrayref of hashrefs for all pending modifications for existing patrons.
=cut
@ -168,7 +168,7 @@ sub GetPendingModifications {
=head2 ApproveModifications
Koha::Borrower::Modifications->ApproveModifications( $borrowernumber );
Koha::Patron::Modifications->ApproveModifications( $borrowernumber );
Commits the pending modifications to the borrower record and removes
them from the modifications table.
@ -197,10 +197,10 @@ sub ApproveModifications {
=head2 DenyModifications
Koha::Borrower::Modifications->DenyModifications( $borrowernumber );
Koha::Patron::Modifications->DenyModifications( $borrowernumber );
Removes the modifications from the table for the given borrower,
without commiting the changes to the borrower record.
Removes the modifications from the table for the given patron,
without committing the changes to the patron record.
=cut
@ -217,7 +217,7 @@ sub DenyModifications {
=head2 DelModifications
Koha::Borrower::Modifications->DelModifications({
Koha::Patron::Modifications->DelModifications({
[ borrowernumber => $borrowernumber ],
[ verification_token => $verification_token ]
});
@ -258,7 +258,7 @@ sub DelModifications {
=head2 GetModifications
$hashref = Koha::Borrower::Modifications->GetModifications({
$hashref = Koha::Patron::Modifications->GetModifications({
[ borrowernumber => $borrowernumber ],
[ verification_token => $verification_token ]
});

View File

@ -1,4 +1,4 @@
package Koha::Borrowers;
package Koha::Patrons;
# Copyright ByWater Solutions 2014
#
@ -23,13 +23,13 @@ use Carp;
use Koha::Database;
use Koha::Borrower;
use Koha::Patron;
use base qw(Koha::Objects);
=head1 NAME
Koha::Borrower - Koha Borrower Object class
Koha::Patron - Koha Patron Object class
=head1 API
@ -46,7 +46,7 @@ sub _type {
}
sub object_class {
return 'Koha::Borrower';
return 'Koha::Patron';
}
=head1 AUTHOR

View File

@ -20,7 +20,7 @@ use Mojo::Base 'Mojolicious';
use C4::Auth qw( check_cookie_auth get_session );
use C4::Context;
use Koha::Borrowers;
use Koha::Patrons;
sub startup {
my $self = shift;
@ -32,7 +32,7 @@ sub startup {
my ($status, $sessionID) = check_cookie_auth($c->cookie('CGISESSID'));
if ($status eq "ok") {
my $session = get_session($sessionID);
my $user = Koha::Borrowers->find($session->param('number'));
my $user = Koha::Patrons->find($session->param('number'));
$c->stash('koha.user' => $user);
}

View File

@ -20,7 +20,7 @@ use Modern::Perl;
use Mojo::Base 'Mojolicious::Controller';
use C4::Auth qw( haspermission );
use Koha::Borrowers;
use Koha::Patrons;
sub list_patrons {
my ($c, $args, $cb) = @_;
@ -30,7 +30,7 @@ sub list_patrons {
return $c->$cb({error => "You don't have the required permission"}, 403);
}
my $patrons = Koha::Borrowers->search;
my $patrons = Koha::Patrons->search;
$c->$cb($patrons->unblessed, 200);
}
@ -47,7 +47,7 @@ sub get_patron {
return $c->$cb({error => "You don't have the required permission"}, 403);
}
my $patron = Koha::Borrowers->find($args->{borrowernumber});
my $patron = Koha::Patrons->find($args->{borrowernumber});
unless ($patron) {
return $c->$cb({error => "Patron not found"}, 404);
}

View File

@ -22,7 +22,7 @@ use Modern::Perl;
use base qw( Template::Plugin );
use Koha::Borrower::Debarments qw();
use Koha::Patron::Debarments qw();
use C4::Members qw();
=pod
@ -46,7 +46,7 @@ sub IsDebarred {
return unless $borrower;
return Koha::Borrower::Debarments::IsDebarred($borrower->{borrowernumber});
return Koha::Patron::Debarments::IsDebarred($borrower->{borrowernumber});
}
sub HasOverdues {

View File

@ -21,7 +21,7 @@ use Carp;
use C4::Auth;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Exceptions;
@ -238,7 +238,7 @@ sub can_be_deleted {
return 0 unless $borrowernumber;
return 1 if $self->owner == $borrowernumber;
my $patron = Koha::Borrowers->find( $borrowernumber );
my $patron = Koha::Patrons->find( $borrowernumber );
return 1 if $self->category == $PUBLIC and C4::Auth::haspermission( $patron->userid, { lists => 'delete_public_lists' } );

View File

@ -35,7 +35,7 @@ use C4::Installer;
use Koha;
use Koha::Acquisition::Currencies;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Config::SysPrefs;
#use Smart::Comments '####';
@ -82,8 +82,8 @@ my $warnPrefAnonymousPatron = (
and not C4::Context->preference('AnonymousPatron')
);
my $anonymous_patron = Koha::Borrowers->find( C4::Context->preference('AnonymousPatron') );
my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Borrowers->search({ privacy => 2 })->count );
my $anonymous_patron = Koha::Patrons->find( C4::Context->preference('AnonymousPatron') );
my $warnPrefAnonymousPatron_PatronDoesNotExist = ( not $anonymous_patron and Koha::Patrons->search({ privacy => 2 })->count );
my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode();

View File

@ -26,7 +26,7 @@ use C4::Auth;
use C4::Branch;
use C4::Output;
use C4::Form::MessagingPreferences;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::Database;
use Koha::DateUtils;
use Koha::Patron::Categories;
@ -162,7 +162,7 @@ elsif ( $op eq 'add_validate' ) {
}
elsif ( $op eq 'delete_confirm' ) {
my $count = Koha::Borrowers->search({
my $count = Koha::Patrons->search({
categorycode => $categorycode
})->count;

View File

@ -43,7 +43,7 @@ use Koha::Holds;
use C4::Context;
use CGI::Session;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
use Koha::DateUtils;
use Koha::Database;
use Koha::Patron::Messages;

View File

@ -28,7 +28,7 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth qw/check_cookie_auth/;
use Koha::Borrowers;
use Koha::Patrons;
use Koha::DateUtils qw/format_sqldatetime/;
use JSON qw( to_json );
@ -67,7 +67,7 @@ foreach my $p (@parts) {
push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
my $borrowers_rs = Koha::Borrowers->search(
my $borrowers_rs = Koha::Patrons->search(
{ -and => \@params },
{
# Get the first 10 results

View File

@ -28,8 +28,8 @@ use C4::NewsChannels; # GetNewsToDisplay
use C4::Review qw/numberofreviews/;
use C4::Suggestions qw/CountSuggestion/;
use C4::Tags qw/get_count_by_tag_status/;
use Koha::Borrower::Modifications;
use Koha::Borrower::Discharge;
use Koha::Patron::Modifications;
use Koha::Patron::Discharge;
my $query = new CGI;
@ -66,8 +66,8 @@ my $pendingcomments = numberofreviews(0);
my $pendingtags = get_count_by_tag_status(0);
my $pendingsuggestions = CountSuggestion("ASKED");
my $pending_borrower_modifications =
Koha::Borrower::Modifications->GetPendingModificationsCount( $branch );
my $pending_discharge_requests = Koha::Borrower::Discharge::count({ pending => 1 });
Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
my $pending_discharge_requests = Koha::Patron::Discharge::count({ pending => 1 });
$template->param(
pendingcomments => $pendingcomments,

View File

@ -36,7 +36,7 @@ use C4::Output;
use C4::Members;
use C4::Reserves;
use C4::Letters;
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
use Koha::DateUtils;
@ -57,7 +57,7 @@ if ( $input->param('borrowernumber') ) {
# Getting member data
$data = GetMember( borrowernumber => $borrowernumber );
my $can_be_discharged = Koha::Borrower::Discharge::can_be_discharged({
my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
borrowernumber => $borrowernumber
});
@ -67,16 +67,16 @@ if ( $input->param('borrowernumber') ) {
# Generating discharge if needed
if ( $input->param('discharge') and $can_be_discharged ) {
my $is_discharged = Koha::Borrower::Discharge::is_discharged({
my $is_discharged = Koha::Patron::Discharge::is_discharged({
borrowernumber => $borrowernumber,
});
unless ($is_discharged) {
Koha::Borrower::Discharge::discharge({
Koha::Patron::Discharge::discharge({
borrowernumber => $borrowernumber
});
}
eval {
my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf(
my $pdf_path = Koha::Patron::Discharge::generate_as_pdf(
{ borrowernumber => $borrowernumber, branchcode => $data->{'branchcode'} } );
binmode(STDOUT);
@ -98,7 +98,7 @@ if ( $input->param('borrowernumber') ) {
}
# Already generated discharges
my $validated_discharges = Koha::Borrower::Discharge::get_validated({
my $validated_discharges = Koha::Patron::Discharge::get_validated({
borrowernumber => $borrowernumber,
});

View File

@ -23,7 +23,7 @@ use CGI;
use C4::Auth;
use C4::Output;
use C4::Context;
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
my $input = new CGI;
my $op = $input->param('op') // 'list';
@ -44,12 +44,12 @@ my $branchcode =
if( $op eq 'allow' ) {
my $borrowernumber = $input->param('borrowernumber');
Koha::Borrower::Discharge::discharge({
Koha::Patron::Discharge::discharge({
borrowernumber => $borrowernumber
}) if $borrowernumber;
}
my $pending_discharges = Koha::Borrower::Discharge::get_pendings({
my $pending_discharges = Koha::Patron::Discharge::get_pendings({
branchcode => $branchcode
});

View File

@ -30,7 +30,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Debug;
use Koha::DateUtils;
use Koha::Borrower::Files;
use Koha::Patron::Files;
my $cgi = CGI->new;
@ -47,7 +47,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
$template->param( 'borrower_files' => 1 );
my $borrowernumber = $cgi->param('borrowernumber');
my $bf = Koha::Borrower::Files->new( borrowernumber => $borrowernumber );
my $bf = Koha::Patron::Files->new( borrowernumber => $borrowernumber );
my $op = $cgi->param('op') || '';
@ -119,7 +119,7 @@ else {
$template->param( picture => 1 ) if $picture;
$template->param(
files => Koha::Borrower::Files->new( borrowernumber => $borrowernumber )
files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
->GetFilesInfo(),
errors => \%errors,

View File

@ -39,7 +39,7 @@ use C4::Log;
use C4::Letters;
use C4::Branch; # GetBranches
use C4::Form::MessagingPreferences;
use Koha::Borrower::Debarments;
use Koha::Patron::Debarments;
use Koha::Cities;
use Koha::DateUtils;
use Email::Valid;

View File

@ -26,7 +26,7 @@ use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
use Koha::Libraries;
use Koha::List::Patron;
@ -89,7 +89,7 @@ else {
my $pending_borrower_modifications =
Koha::Borrower::Modifications->GetPendingModificationsCount( $branch );
Koha::Patron::Modifications->GetPendingModificationsCount( $branch );
$template->param(
no_add => $no_add,

View File

@ -26,7 +26,7 @@ use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $query = new CGI;
@ -50,10 +50,10 @@ foreach my $param (@params) {
my $action = $query->param($param);
if ( $action eq 'approve' ) {
Koha::Borrower::Modifications->ApproveModifications( $borrowernumber );
Koha::Patron::Modifications->ApproveModifications( $borrowernumber );
}
elsif ( $action eq 'deny' ) {
Koha::Borrower::Modifications->DenyModifications( $borrowernumber );
Koha::Patron::Modifications->DenyModifications( $borrowernumber );
}
elsif ( $action eq 'ignore' ) {

View File

@ -26,7 +26,7 @@ use C4::Context;
use C4::Members;
use C4::Branch;
use C4::Category;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $query = new CGI;
@ -49,7 +49,7 @@ my $branch =
: undef;
my $pending_modifications =
Koha::Borrower::Modifications->GetPendingModifications($branch);
Koha::Patron::Modifications->GetPendingModifications($branch);
my $borrowers;
foreach my $pm (@$pending_modifications) {

View File

@ -23,7 +23,7 @@ use CGI qw ( -utf8 );
use C4::Auth;
use Koha::DateUtils;
use Koha::Borrower::Debarments;
use Koha::Patron::Debarments;
my $cgi = new CGI;

View File

@ -51,8 +51,7 @@ use C4::Branch; # GetBranchName
use C4::Form::MessagingPreferences;
use List::MoreUtils qw/uniq/;
use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Borrower::Debarments qw(GetDebarments IsDebarred);
use Koha::Libraries;
use Koha::Patron::Debarments qw(GetDebarments IsDebarred);
use Module::Load;
if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) {
load Koha::NorwegianPatronDB, qw( NLGetSyncDataFromBorrowernumber );

View File

@ -364,7 +364,7 @@ sub PurgeZ3950 {
}
sub PurgeDebarments {
require Koha::Borrower::Debarments;
require Koha::Patron::Debarments;
my $days = shift;
$count = 0;
$sth = $dbh->prepare(
@ -376,7 +376,7 @@ sub PurgeDebarments {
);
$sth->execute($days) or die $dbh->errstr;
while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) {
Koha::Borrower::Debarments::DelDebarment($borrower_debarment_id);
Koha::Patron::Debarments::DelDebarment($borrower_debarment_id);
$count++;
}
return $count;

View File

@ -39,7 +39,7 @@ use C4::Circulation qw/LostItem/;
use Getopt::Long;
use C4::Log;
use Pod::Usage;
use Koha::Borrowers;
use Koha::Patrons;
my $lost; # key=lost value, value=num days.
my ($charge, $verbose, $confirm, $quiet);
@ -302,7 +302,7 @@ foreach my $startrange (sort keys %$lost) {
$count=0;
ITEM: while (my $row=$sth_items->fetchrow_hashref) {
if( $filter_borrower_categories ) {
my $category = uc Koha::Borrowers->find( $row->{borrowernumber} )->categorycode();
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode();
next ITEM unless ( $category_to_process{ $category } );
}
printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);

View File

@ -38,7 +38,7 @@ use C4::Context;
use C4::Letters;
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
use C4::Log;
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
use Koha::Patron::Debarments qw(AddUniqueDebarment);
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Libraries;

View File

@ -28,7 +28,7 @@ use C4::Log;
use C4::Debug;
use C4::Branch;
use C4::Members;
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
use Koha::DateUtils;
my $input = new CGI;
@ -44,7 +44,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
});
if ( $op eq 'request' ) {
my $success = Koha::Borrower::Discharge::request({
my $success = Koha::Patron::Discharge::request({
borrowernumber => $loggedinuser,
});
@ -60,7 +60,7 @@ elsif ( $op eq 'get' ) {
# Getting member data
my $data = GetMember( borrowernumber => $loggedinuser );
my $pdf_path = Koha::Borrower::Discharge::generate_as_pdf({
my $pdf_path = Koha::Patron::Discharge::generate_as_pdf({
borrowernumber => $loggedinuser,
branchcode => $data->{'branchcode'},
});
@ -83,16 +83,16 @@ elsif ( $op eq 'get' ) {
}
}
else {
my $pending = Koha::Borrower::Discharge::count({
my $pending = Koha::Patron::Discharge::count({
borrowernumber => $loggedinuser,
pending => 1,
});
my $available = Koha::Borrower::Discharge::count({
my $available = Koha::Patron::Discharge::count({
borrowernumber => $loggedinuser,
validated => 1,
});
$template->param(
available => $available && Koha::Borrower::Discharge::is_discharged({borrowernumber => $loggedinuser}),
available => $available && Koha::Patron::Discharge::is_discharged({borrowernumber => $loggedinuser}),
pending => $pending,
);
}

View File

@ -25,8 +25,8 @@ use C4::Auth;
use C4::Output;
use C4::Members;
use C4::Form::MessagingPreferences;
use Koha::Borrowers;
use Koha::Borrower::Modifications;
use Koha::Patrons;
use Koha::Patron::Modifications;
use C4::Branch qw(GetBranchesLoop);
use C4::Scrubber;
use Email::Valid;
@ -126,7 +126,8 @@ if ( $action eq 'create' ) {
my $verification_token = md5_hex( \%borrower );
$borrower{'password'} = random_string("..........");
Koha::Borrower::Modifications->new(
Koha::Patron::Modifications->new(
verification_token => $verification_token )
->AddModifications(\%borrower);
@ -207,7 +208,7 @@ elsif ( $action eq 'update' ) {
);
my $m =
Koha::Borrower::Modifications->new(
Koha::Patron::Modifications->new(
borrowernumber => $borrowernumber );
$m->DelModifications;
@ -238,7 +239,7 @@ elsif ( $action eq 'edit' ) { #Display logged in borrower's data
$template->param(
borrower => $borrower,
guarantor => scalar Koha::Borrowers->find($borrowernumber)->guarantor(),
guarantor => scalar Koha::Patrons->find($borrowernumber)->guarantor(),
hidden => GetHiddenFields( $mandatory, 'modification' ),
);

View File

@ -24,7 +24,7 @@ use C4::Context;
use C4::Circulation;
use C4::Members;
use C4::Output;
use Koha::Borrowers;
use Koha::Patrons;
my $query = new CGI;
@ -75,7 +75,7 @@ elsif ( $op eq "delete_record" ) {
}
# get borrower privacy ....
my $borrower = Koha::Borrowers->find( $borrowernumber );;
my $borrower = Koha::Patrons->find( $borrowernumber );;
$template->param(
'Ask_data' => 1,

View File

@ -23,7 +23,7 @@ use C4::Auth;
use C4::Output;
use C4::Members;
use C4::Form::MessagingPreferences;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $cgi = new CGI;
my $dbh = C4::Context->dbh;
@ -34,7 +34,7 @@ unless ( C4::Context->preference('PatronSelfRegistration') ) {
}
my $token = $cgi->param('token');
my $m = Koha::Borrower::Modifications->new( verification_token => $token );
my $m = Koha::Patron::Modifications->new( verification_token => $token );
my ( $template, $borrowernumber, $cookie );
if ( $m->Verify() ) {
@ -50,13 +50,13 @@ if ( $m->Verify() ) {
$template->param(
OpacPasswordChange => C4::Context->preference('OpacPasswordChange') );
my $borrower = Koha::Borrower::Modifications->GetModifications({ verification_token => $token });
my $borrower = Koha::Patron::Modifications->GetModifications({ verification_token => $token });
my $password;
( $borrowernumber, $password ) = AddMember_Opac(%$borrower);
if ($borrowernumber) {
Koha::Borrower::Modifications->DelModifications({ verification_token => $token });
Koha::Patron::Modifications->DelModifications({ verification_token => $token });
C4::Form::MessagingPreferences::handle_form_action($cgi, { borrowernumber => $borrowernumber }, $template, 1, C4::Context->preference('PatronSelfRegistrationDefaultCategory') ) if C4::Context->preference('EnhancedMessagingPreferences');
$template->param( password_cleartext => $password );

View File

@ -34,8 +34,8 @@ use C4::Branch; # GetBranches
use C4::Overdues;
use C4::Debug;
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Libraries;
use Koha::Patron::Debarments qw(IsDebarred);
use Date::Calc qw/Today Date_to_Days/;
my $maxreserves = C4::Context->preference("maxreserves");

View File

@ -35,7 +35,7 @@ use C4::Items;
use C4::Letters;
use C4::Branch; # GetBranches
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Patron::Debarments qw(IsDebarred);
use Koha::Holds;
use Koha::Database;
use Koha::Patron::Messages;

View File

@ -44,7 +44,7 @@ use C4::Utils::DataTables::Members;
use C4::Members;
use C4::Search; # enabled_staff_search_views
use Koha::DateUtils;
use Koha::Borrower::Debarments qw(IsDebarred);
use Koha::Patron::Debarments qw(IsDebarred);
use Koha::Holds;
use Koha::Libraries;

View File

@ -1,343 +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 Test::More tests => 18;
use Test::Warn;
use t::lib::Mocks;
BEGIN {
t::lib::Mocks::mock_dbh;
use_ok('Koha::Object');
use_ok('Koha::Borrower');
}
my $object = Koha::Borrower->new( { surname => 'Test Borrower' } );
is( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
$object->surname('Test Borrower Surname');
is( $object->surname(), 'Test Borrower Surname', "Accessor returns correct value after set" );
my $object2 = Koha::Borrower->new( { surname => 'Test Borrower 2' } );
is( $object2->surname(), 'Test Borrower 2', "Accessor returns correct value" );
$object2->surname('Test Borrower Surname 2');
is( $object2->surname(), 'Test Borrower Surname 2', "Accessor returns correct value after set" );
my $ret;
$ret = $object2->set( { surname => "Test Borrower Surname 3", firstname => "Test Firstname" } );
ok( ref($ret) eq 'Koha::Borrower', "Set returns object on success" );
is( $object2->surname(), "Test Borrower Surname 3", "Set sets first field correctly" );
is( $object2->firstname(), "Test Firstname", "Set sets second field correctly" );
warning_is { $ret = $object->set({ surname => "Test Borrower Surname 4", bork => "bork" }) }
"No property bork!",
"Expected 'No property bork!' caught";
is( $object2->surname(), "Test Borrower Surname 3", "Bad Set does not set field" );
is( $ret, 0, "Set returns 0 when passed a bad property" );
warning_is { $ret = $object->bork() }
"No method bork!",
"Expected 'No method bork!' caught for getter.";
ok( ! defined $ret, 'Bad getter returns undef' );
warning_is { $ret = $object->bork('bork') }
"No method bork!",
"Expected 'No method bork!' caught for setter.";
ok( ! defined $ret, 'Bad setter returns undef' );
my $borrower = Koha::Borrower->new(
{
borrowernumber => '12345',
cardnumber => '1234567890',
surname => 'mySurname',
firstname => 'myFirstname',
title => 'Mr.',
othernames => 'myOthernames',
initials => 'MM',
streetnumber => '100',
streettype => 'Blvd',
address => 'my personnal address',
address2 => 'my adress2',
city => 'Marseille',
state => 'mystate',
zipcode => '13006',
country => 'France',
email => 'mySurname.myFirstname@email.com',
phone => '0402872934',
mobile => '0627884632',
fax => '0402872935',
emailpro => 'myEmailPro@email.com',
phonepro => '0402873334',
B_streetnumber => '101',
B_streettype => 'myB_streettype',
B_address => 'myB_address',
B_address2 => 'myB_address2',
B_city => 'myB_city',
B_state => 'myB_state',
B_zipcode => '23456',
B_country => 'myB_country',
B_email => 'myB_email',
B_phone => '0678353935',
dateofbirth => '1990-07-16',
branchcode => 'myBranCode',
categorycode => 'myCatCode',
dateenrolled => '2015-03-19',
dateexpiry => '2016-03-19',
gonenoaddress => '0',
lost => '0',
debarred => '2015-04-19',
debarredcomment => 'You are debarred',
contactname => 'myContactname',
contactfirstname => 'myContactfirstname',
contacttitle => 'myContacttitle',
guarantorid => '123454321',
borrowernotes => 'borrowernotes',
relationship => 'myRelationship',
sex => 'M',
password => 'hfkurhfe976634èj!',
flags => '55555',
userid => '87987',
opacnote => 'myOpacnote',
contactnote => 'myContactnote',
sort1 => 'mySort1',
sort2 => 'mySort2',
altcontactfirstname => 'myAltcontactfirstname',
altcontactsurname => 'myAltcontactsurname',
altcontactaddress1 => 'myAltcontactaddress1',
altcontactaddress2 => 'myAltcontactaddress2',
altcontactaddress3 => 'myAltcontactaddress3',
altcontactstate => 'myAltcontactstate',
altcontactzipcode => '465843',
altcontactcountry => 'myOtherCountry',
altcontactphone => 'myOtherphone',
smsalertnumber => '0683027346',
privacy => '667788',
}
);
#borrower Accessor tests
subtest 'Accessor tests' => sub {
plan tests => 65;
is( $borrower->borrowernumber, '12345', 'borrowernumber accessor returns correct value' );
is( $borrower->cardnumber, '1234567890', 'cardnumber accessor returns correct value' );
is( $borrower->surname, 'mySurname', 'surname accessor returns correct value' );
is( $borrower->firstname, 'myFirstname', 'firstname accessor returns correct value' );
is( $borrower->title, 'Mr.', 'title accessor returns correct value' );
is( $borrower->othernames, 'myOthernames', 'othernames accessor returns correct value' );
is( $borrower->initials, 'MM', 'initials accessor returns correct value' );
is( $borrower->streetnumber, '100', 'streetnumber accessor returns correct value' );
is( $borrower->streettype, 'Blvd', 'streettype accessor returns correct value' );
is( $borrower->address, 'my personnal address', 'address accessor returns correct value' );
is( $borrower->address2, 'my adress2', 'address2 accessor returns correct value' );
is( $borrower->city, 'Marseille', 'city accessor returns correct value' );
is( $borrower->state, 'mystate', 'state accessor returns correct value' );
is( $borrower->zipcode, '13006', 'zipcode accessor returns correct value' );
is( $borrower->country, 'France', 'country accessor returns correct value' );
is( $borrower->email, 'mySurname.myFirstname@email.com', 'email accessor returns correct value' );
is( $borrower->phone, '0402872934', 'phone accessor returns correct value' );
is( $borrower->mobile, '0627884632', 'mobile accessor returns correct value' );
is( $borrower->fax, '0402872935', 'fax accessor returns correct value' );
is( $borrower->emailpro, 'myEmailPro@email.com', 'emailpro accessor returns correct value' );
is( $borrower->phonepro, '0402873334', 'phonepro accessor returns correct value' );
is( $borrower->B_streetnumber, '101', 'B_streetnumber accessor returns correct value' );
is( $borrower->B_streettype, 'myB_streettype', 'B_streettype accessor returns correct value' );
is( $borrower->B_address, 'myB_address', 'B_address accessor returns correct value' );
is( $borrower->B_address2, 'myB_address2', 'B_address2 accessor returns correct value' );
is( $borrower->B_city, 'myB_city', 'B_city accessor returns correct value' );
is( $borrower->B_state, 'myB_state', 'B_state accessor returns correct value' );
is( $borrower->B_zipcode, '23456', 'B_zipcode accessor returns correct value' );
is( $borrower->B_country, 'myB_country', 'B_country accessor returns correct value' );
is( $borrower->B_email, 'myB_email', 'B_email accessor returns correct value' );
is( $borrower->B_phone, '0678353935', 'B_phone accessor returns correct value' );
is( $borrower->dateofbirth, '1990-07-16', 'dateofbirth accessor returns correct value' );
is( $borrower->branchcode, 'myBranCode', 'branchcode accessor returns correct value' );
is( $borrower->categorycode, 'myCatCode', 'categorycode accessor returns correct value' );
is( $borrower->dateenrolled, '2015-03-19', 'dateenrolled accessor returns correct value' );
is( $borrower->dateexpiry, '2016-03-19', 'dateexpiry accessor returns correct value' );
is( $borrower->gonenoaddress, '0', 'gonenoaddress accessor returns correct value' );
is( $borrower->lost, '0', 'lost accessor returns correct value' );
is( $borrower->debarred, '2015-04-19', 'debarred accessor returns correct value' );
is( $borrower->debarredcomment, 'You are debarred', 'debarredcomment accessor returns correct value' );
is( $borrower->contactname, 'myContactname', 'contactname accessor returns correct value' );
is( $borrower->contactfirstname, 'myContactfirstname', 'contactfirstname accessor returns correct value' );
is( $borrower->contacttitle, 'myContacttitle', 'contacttitle accessor returns correct value' );
is( $borrower->guarantorid, '123454321', 'guarantorid accessor returns correct value' );
is( $borrower->borrowernotes, 'borrowernotes', 'borrowernotes accessor returns correct value' );
is( $borrower->relationship, 'myRelationship', 'relationship accessor returns correct value' );
is( $borrower->sex, 'M', 'sex accessor returns correct value' );
is( $borrower->password, 'hfkurhfe976634èj!', 'password accessor returns correct value' );
is( $borrower->flags, '55555', 'flags accessor returns correct value' );
is( $borrower->userid, '87987', 'userid accessor returns correct value' );
is( $borrower->opacnote, 'myOpacnote', 'opacnote accessor returns correct value' );
is( $borrower->contactnote, 'myContactnote', 'contactnote accessor returns correct value' );
is( $borrower->sort1, 'mySort1', 'sort1 accessor returns correct value' );
is( $borrower->sort2, 'mySort2', 'sort2 accessor returns correct value' );
is( $borrower->altcontactfirstname, 'myAltcontactfirstname', 'altcontactfirstname accessor returns correct value' );
is( $borrower->altcontactsurname, 'myAltcontactsurname', 'altcontactsurname accessor returns correct value' );
is( $borrower->altcontactaddress1, 'myAltcontactaddress1', 'altcontactaddress1 accessor returns correct value' );
is( $borrower->altcontactaddress2, 'myAltcontactaddress2', 'altcontactaddress2 accessor returns correct value' );
is( $borrower->altcontactaddress3, 'myAltcontactaddress3', 'altcontactaddress3 accessor returns correct value' );
is( $borrower->altcontactstate, 'myAltcontactstate', 'altcontactstate accessor returns correct value' );
is( $borrower->altcontactzipcode, '465843', 'altcontactzipcode accessor returns correct value' );
is( $borrower->altcontactcountry, 'myOtherCountry', 'altcontactcountry accessor returns correct value' );
is( $borrower->altcontactphone, 'myOtherphone', 'altcontactphone accessor returns correct value' );
is( $borrower->smsalertnumber, '0683027346', 'smsalertnumber accessor returns correct value' );
is( $borrower->privacy, '667788', 'privacy accessor returns correct value' );
};
#borrower Set tests
subtest 'Set tests' => sub {
plan tests => 65;
$borrower->set(
{
borrowernumber => '12346',
cardnumber => '1234567891',
surname => 'SmySurname',
firstname => 'SmyFirstname',
title => 'Mme.',
othernames => 'SmyOthernames',
initials => 'SS',
streetnumber => '200',
streettype => 'Rue',
address => 'Smy personnal address',
address2 => 'Smy adress2',
city => 'Lyon',
state => 'Smystate',
zipcode => '69000',
country => 'France',
email => 'SmySurname.myFirstname@email.com',
phone => '0402872935',
mobile => '0627884633',
fax => '0402872936',
emailpro => 'SmyEmailPro@email.com',
phonepro => '0402873335',
B_streetnumber => '102',
B_streettype => 'SmyB_streettype',
B_address => 'SmyB_address',
B_address2 => 'SmyB_address2',
B_city => 'SmyB_city',
B_state => 'SmyB_state',
B_zipcode => '12333',
B_country => 'SmyB_country',
B_email => 'SmyB_email',
B_phone => '0678353936',
dateofbirth => '1991-07-16',
branchcode => 'SmyBranCode',
categorycode => 'SmyCatCode',
dateenrolled => '2014-03-19',
dateexpiry => '2017-03-19',
gonenoaddress => '1',
lost => '1',
debarred => '2016-04-19',
debarredcomment => 'You are still debarred',
contactname => 'SmyContactname',
contactfirstname => 'SmyContactfirstname',
contacttitle => 'SmyContacttitle',
guarantorid => '223454321',
borrowernotes => 'Sborrowernotes',
relationship => 'SmyRelationship',
sex => 'F',
password => 'zerzerzer#',
flags => '666666',
userid => '98233',
opacnote => 'SmyOpacnote',
contactnote => 'SmyContactnote',
sort1 => 'SmySort1',
sort2 => 'SmySort2',
altcontactfirstname => 'SmyAltcontactfirstname',
altcontactsurname => 'SmyAltcontactsurname',
altcontactaddress1 => 'SmyAltcontactaddress1',
altcontactaddress2 => 'SmyAltcontactaddress2',
altcontactaddress3 => 'SmyAltcontactaddress3',
altcontactstate => 'SmyAltcontactstate',
altcontactzipcode => '565843',
altcontactcountry => 'SmyOtherCountry',
altcontactphone => 'SmyOtherphone',
smsalertnumber => '0683027347',
privacy => '667789'
}
);
is( $borrower->borrowernumber, '12346', 'borrowernumber field set ok' );
is( $borrower->cardnumber, '1234567891', 'cardnumber field set ok' );
is( $borrower->surname, 'SmySurname', 'surname field set ok' );
is( $borrower->firstname, 'SmyFirstname', 'firstname field set ok' );
is( $borrower->title, 'Mme.', 'title field set ok' );
is( $borrower->othernames, 'SmyOthernames', 'othernames field set ok' );
is( $borrower->initials, 'SS', 'initials field set ok' );
is( $borrower->streetnumber, '200', 'streetnumber field set ok' );
is( $borrower->streettype, 'Rue', 'streettype field set ok' );
is( $borrower->address, 'Smy personnal address', 'address field set ok' );
is( $borrower->address2, 'Smy adress2', 'address2 field set ok' );
is( $borrower->city, 'Lyon', 'city field set ok' );
is( $borrower->state, 'Smystate', 'state field set ok' );
is( $borrower->zipcode, '69000', 'zipcode field set ok' );
is( $borrower->country, 'France', 'country field set ok' );
is( $borrower->email, 'SmySurname.myFirstname@email.com', 'email field set ok' );
is( $borrower->phone, '0402872935', 'phone field set ok' );
is( $borrower->mobile, '0627884633', 'mobile field set ok' );
is( $borrower->fax, '0402872936', 'fax field set ok' );
is( $borrower->emailpro, 'SmyEmailPro@email.com', 'emailpro field set ok' );
is( $borrower->phonepro, '0402873335', 'phonepro field set ok' );
is( $borrower->B_streetnumber, '102', 'B_streetnumber field set ok' );
is( $borrower->B_streettype, 'SmyB_streettype', 'B_streettype field set ok' );
is( $borrower->B_address, 'SmyB_address', 'B_address field set ok' );
is( $borrower->B_address2, 'SmyB_address2', 'B_address2 field set ok' );
is( $borrower->B_city, 'SmyB_city', 'B_city field set ok' );
is( $borrower->B_state, 'SmyB_state', 'B_state field set ok' );
is( $borrower->B_zipcode, '12333', 'B_zipcode field set ok' );
is( $borrower->B_country, 'SmyB_country', 'B_country field set ok' );
is( $borrower->B_email, 'SmyB_email', 'B_email field set ok' );
is( $borrower->B_phone, '0678353936', 'B_phone field set ok' );
is( $borrower->dateofbirth, '1991-07-16', 'dateofbirth field set ok' );
is( $borrower->branchcode, 'SmyBranCode', 'branchcode field set ok' );
is( $borrower->categorycode, 'SmyCatCode', 'categorycode field set ok' );
is( $borrower->dateenrolled, '2014-03-19', 'dateenrolled field set ok' );
is( $borrower->dateexpiry, '2017-03-19', 'dateexpiry field set ok' );
is( $borrower->gonenoaddress, '1', 'gonenoaddress field set ok' );
is( $borrower->lost, '1', 'lost field set ok' );
is( $borrower->debarred, '2016-04-19', 'debarred field set ok' );
is( $borrower->debarredcomment, 'You are still debarred', 'debarredcomment field set ok' );
is( $borrower->contactname, 'SmyContactname', 'contactname field set ok' );
is( $borrower->contactfirstname, 'SmyContactfirstname', 'contactfirstname field set ok' );
is( $borrower->contacttitle, 'SmyContacttitle', 'contacttitle field set ok' );
is( $borrower->guarantorid, '223454321', 'guarantorid field set ok' );
is( $borrower->borrowernotes, 'Sborrowernotes', 'borrowernotes field set ok' );
is( $borrower->relationship, 'SmyRelationship', 'relationship field set ok' );
is( $borrower->sex, 'F', 'sex field set ok' );
is( $borrower->password, 'zerzerzer#', 'password field set ok' );
is( $borrower->flags, '666666', 'flags field set ok' );
is( $borrower->userid, '98233', 'userid field set ok' );
is( $borrower->opacnote, 'SmyOpacnote', 'opacnote field set ok' );
is( $borrower->contactnote, 'SmyContactnote', 'contactnote field set ok' );
is( $borrower->sort1, 'SmySort1', 'sort1 field set ok' );
is( $borrower->sort2, 'SmySort2', 'sort2 field set ok' );
is( $borrower->altcontactfirstname, 'SmyAltcontactfirstname', 'altcontactfirstname field set ok' );
is( $borrower->altcontactsurname, 'SmyAltcontactsurname', 'altcontactsurname field set ok' );
is( $borrower->altcontactaddress1, 'SmyAltcontactaddress1', 'altcontactaddress1 field set ok' );
is( $borrower->altcontactaddress2, 'SmyAltcontactaddress2', 'altcontactaddress2 field set ok' );
is( $borrower->altcontactaddress3, 'SmyAltcontactaddress3', 'altcontactaddress3 field set ok' );
is( $borrower->altcontactstate, 'SmyAltcontactstate', 'altcontactstate field set ok' );
is( $borrower->altcontactzipcode, '565843', 'altcontactzipcode field set ok' );
is( $borrower->altcontactcountry, 'SmyOtherCountry', 'altcontactcountry field set ok' );
is( $borrower->altcontactphone, 'SmyOtherphone', 'altcontactphone field set ok' );
is( $borrower->smsalertnumber, '0683027347', 'smsalertnumber field set ok' );
is( $borrower->privacy, '667789', 'privacy field set ok' );
};
1;

343
t/Patron.t Executable file
View File

@ -0,0 +1,343 @@
#!/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 Test::More tests => 18;
use Test::Warn;
use t::lib::Mocks;
BEGIN {
t::lib::Mocks::mock_dbh;
use_ok('Koha::Object');
use_ok('Koha::Patron');
}
my $object = Koha::Patron->new( { surname => 'Test Patron' } );
is( $object->surname(), 'Test Patron', "Accessor returns correct value" );
$object->surname('Test Patron Surname');
is( $object->surname(), 'Test Patron Surname', "Accessor returns correct value after set" );
my $object2 = Koha::Patron->new( { surname => 'Test Patron 2' } );
is( $object2->surname(), 'Test Patron 2', "Accessor returns correct value" );
$object2->surname('Test Patron Surname 2');
is( $object2->surname(), 'Test Patron Surname 2', "Accessor returns correct value after set" );
my $ret;
$ret = $object2->set( { surname => "Test Patron Surname 3", firstname => "Test Firstname" } );
ok( ref($ret) eq 'Koha::Patron', "Set returns object on success" );
is( $object2->surname(), "Test Patron Surname 3", "Set sets first field correctly" );
is( $object2->firstname(), "Test Firstname", "Set sets second field correctly" );
warning_is { $ret = $object->set({ surname => "Test Patron Surname 4", bork => "bork" }) }
"No property bork!",
"Expected 'No property bork!' caught";
is( $object2->surname(), "Test Patron Surname 3", "Bad Set does not set field" );
is( $ret, 0, "Set returns 0 when passed a bad property" );
warning_is { $ret = $object->bork() }
"No method bork!",
"Expected 'No method bork!' caught for getter.";
ok( ! defined $ret, 'Bad getter returns undef' );
warning_is { $ret = $object->bork('bork') }
"No method bork!",
"Expected 'No method bork!' caught for setter.";
ok( ! defined $ret, 'Bad setter returns undef' );
my $patron = Koha::Patron->new(
{
borrowernumber => '12345',
cardnumber => '1234567890',
surname => 'mySurname',
firstname => 'myFirstname',
title => 'Mr.',
othernames => 'myOthernames',
initials => 'MM',
streetnumber => '100',
streettype => 'Blvd',
address => 'my personnal address',
address2 => 'my adress2',
city => 'Marseille',
state => 'mystate',
zipcode => '13006',
country => 'France',
email => 'mySurname.myFirstname@email.com',
phone => '0402872934',
mobile => '0627884632',
fax => '0402872935',
emailpro => 'myEmailPro@email.com',
phonepro => '0402873334',
B_streetnumber => '101',
B_streettype => 'myB_streettype',
B_address => 'myB_address',
B_address2 => 'myB_address2',
B_city => 'myB_city',
B_state => 'myB_state',
B_zipcode => '23456',
B_country => 'myB_country',
B_email => 'myB_email',
B_phone => '0678353935',
dateofbirth => '1990-07-16',
branchcode => 'myBranCode',
categorycode => 'myCatCode',
dateenrolled => '2015-03-19',
dateexpiry => '2016-03-19',
gonenoaddress => '0',
lost => '0',
debarred => '2015-04-19',
debarredcomment => 'You are debarred',
contactname => 'myContactname',
contactfirstname => 'myContactfirstname',
contacttitle => 'myContacttitle',
guarantorid => '123454321',
borrowernotes => 'borrowernotes',
relationship => 'myRelationship',
sex => 'M',
password => 'hfkurhfe976634èj!',
flags => '55555',
userid => '87987',
opacnote => 'myOpacnote',
contactnote => 'myContactnote',
sort1 => 'mySort1',
sort2 => 'mySort2',
altcontactfirstname => 'myAltcontactfirstname',
altcontactsurname => 'myAltcontactsurname',
altcontactaddress1 => 'myAltcontactaddress1',
altcontactaddress2 => 'myAltcontactaddress2',
altcontactaddress3 => 'myAltcontactaddress3',
altcontactstate => 'myAltcontactstate',
altcontactzipcode => '465843',
altcontactcountry => 'myOtherCountry',
altcontactphone => 'myOtherphone',
smsalertnumber => '0683027346',
privacy => '667788',
}
);
# patron Accessor tests
subtest 'Accessor tests' => sub {
plan tests => 65;
is( $patron->borrowernumber, '12345', 'borrowernumber accessor returns correct value' );
is( $patron->cardnumber, '1234567890', 'cardnumber accessor returns correct value' );
is( $patron->surname, 'mySurname', 'surname accessor returns correct value' );
is( $patron->firstname, 'myFirstname', 'firstname accessor returns correct value' );
is( $patron->title, 'Mr.', 'title accessor returns correct value' );
is( $patron->othernames, 'myOthernames', 'othernames accessor returns correct value' );
is( $patron->initials, 'MM', 'initials accessor returns correct value' );
is( $patron->streetnumber, '100', 'streetnumber accessor returns correct value' );
is( $patron->streettype, 'Blvd', 'streettype accessor returns correct value' );
is( $patron->address, 'my personnal address', 'address accessor returns correct value' );
is( $patron->address2, 'my adress2', 'address2 accessor returns correct value' );
is( $patron->city, 'Marseille', 'city accessor returns correct value' );
is( $patron->state, 'mystate', 'state accessor returns correct value' );
is( $patron->zipcode, '13006', 'zipcode accessor returns correct value' );
is( $patron->country, 'France', 'country accessor returns correct value' );
is( $patron->email, 'mySurname.myFirstname@email.com', 'email accessor returns correct value' );
is( $patron->phone, '0402872934', 'phone accessor returns correct value' );
is( $patron->mobile, '0627884632', 'mobile accessor returns correct value' );
is( $patron->fax, '0402872935', 'fax accessor returns correct value' );
is( $patron->emailpro, 'myEmailPro@email.com', 'emailpro accessor returns correct value' );
is( $patron->phonepro, '0402873334', 'phonepro accessor returns correct value' );
is( $patron->B_streetnumber, '101', 'B_streetnumber accessor returns correct value' );
is( $patron->B_streettype, 'myB_streettype', 'B_streettype accessor returns correct value' );
is( $patron->B_address, 'myB_address', 'B_address accessor returns correct value' );
is( $patron->B_address2, 'myB_address2', 'B_address2 accessor returns correct value' );
is( $patron->B_city, 'myB_city', 'B_city accessor returns correct value' );
is( $patron->B_state, 'myB_state', 'B_state accessor returns correct value' );
is( $patron->B_zipcode, '23456', 'B_zipcode accessor returns correct value' );
is( $patron->B_country, 'myB_country', 'B_country accessor returns correct value' );
is( $patron->B_email, 'myB_email', 'B_email accessor returns correct value' );
is( $patron->B_phone, '0678353935', 'B_phone accessor returns correct value' );
is( $patron->dateofbirth, '1990-07-16', 'dateofbirth accessor returns correct value' );
is( $patron->branchcode, 'myBranCode', 'branchcode accessor returns correct value' );
is( $patron->categorycode, 'myCatCode', 'categorycode accessor returns correct value' );
is( $patron->dateenrolled, '2015-03-19', 'dateenrolled accessor returns correct value' );
is( $patron->dateexpiry, '2016-03-19', 'dateexpiry accessor returns correct value' );
is( $patron->gonenoaddress, '0', 'gonenoaddress accessor returns correct value' );
is( $patron->lost, '0', 'lost accessor returns correct value' );
is( $patron->debarred, '2015-04-19', 'debarred accessor returns correct value' );
is( $patron->debarredcomment, 'You are debarred', 'debarredcomment accessor returns correct value' );
is( $patron->contactname, 'myContactname', 'contactname accessor returns correct value' );
is( $patron->contactfirstname, 'myContactfirstname', 'contactfirstname accessor returns correct value' );
is( $patron->contacttitle, 'myContacttitle', 'contacttitle accessor returns correct value' );
is( $patron->guarantorid, '123454321', 'guarantorid accessor returns correct value' );
is( $patron->borrowernotes, 'borrowernotes', 'borrowernotes accessor returns correct value' );
is( $patron->relationship, 'myRelationship', 'relationship accessor returns correct value' );
is( $patron->sex, 'M', 'sex accessor returns correct value' );
is( $patron->password, 'hfkurhfe976634èj!', 'password accessor returns correct value' );
is( $patron->flags, '55555', 'flags accessor returns correct value' );
is( $patron->userid, '87987', 'userid accessor returns correct value' );
is( $patron->opacnote, 'myOpacnote', 'opacnote accessor returns correct value' );
is( $patron->contactnote, 'myContactnote', 'contactnote accessor returns correct value' );
is( $patron->sort1, 'mySort1', 'sort1 accessor returns correct value' );
is( $patron->sort2, 'mySort2', 'sort2 accessor returns correct value' );
is( $patron->altcontactfirstname, 'myAltcontactfirstname', 'altcontactfirstname accessor returns correct value' );
is( $patron->altcontactsurname, 'myAltcontactsurname', 'altcontactsurname accessor returns correct value' );
is( $patron->altcontactaddress1, 'myAltcontactaddress1', 'altcontactaddress1 accessor returns correct value' );
is( $patron->altcontactaddress2, 'myAltcontactaddress2', 'altcontactaddress2 accessor returns correct value' );
is( $patron->altcontactaddress3, 'myAltcontactaddress3', 'altcontactaddress3 accessor returns correct value' );
is( $patron->altcontactstate, 'myAltcontactstate', 'altcontactstate accessor returns correct value' );
is( $patron->altcontactzipcode, '465843', 'altcontactzipcode accessor returns correct value' );
is( $patron->altcontactcountry, 'myOtherCountry', 'altcontactcountry accessor returns correct value' );
is( $patron->altcontactphone, 'myOtherphone', 'altcontactphone accessor returns correct value' );
is( $patron->smsalertnumber, '0683027346', 'smsalertnumber accessor returns correct value' );
is( $patron->privacy, '667788', 'privacy accessor returns correct value' );
};
# patron Set tests
subtest 'Set tests' => sub {
plan tests => 65;
$patron->set(
{
borrowernumber => '12346',
cardnumber => '1234567891',
surname => 'SmySurname',
firstname => 'SmyFirstname',
title => 'Mme.',
othernames => 'SmyOthernames',
initials => 'SS',
streetnumber => '200',
streettype => 'Rue',
address => 'Smy personnal address',
address2 => 'Smy adress2',
city => 'Lyon',
state => 'Smystate',
zipcode => '69000',
country => 'France',
email => 'SmySurname.myFirstname@email.com',
phone => '0402872935',
mobile => '0627884633',
fax => '0402872936',
emailpro => 'SmyEmailPro@email.com',
phonepro => '0402873335',
B_streetnumber => '102',
B_streettype => 'SmyB_streettype',
B_address => 'SmyB_address',
B_address2 => 'SmyB_address2',
B_city => 'SmyB_city',
B_state => 'SmyB_state',
B_zipcode => '12333',
B_country => 'SmyB_country',
B_email => 'SmyB_email',
B_phone => '0678353936',
dateofbirth => '1991-07-16',
branchcode => 'SmyBranCode',
categorycode => 'SmyCatCode',
dateenrolled => '2014-03-19',
dateexpiry => '2017-03-19',
gonenoaddress => '1',
lost => '1',
debarred => '2016-04-19',
debarredcomment => 'You are still debarred',
contactname => 'SmyContactname',
contactfirstname => 'SmyContactfirstname',
contacttitle => 'SmyContacttitle',
guarantorid => '223454321',
borrowernotes => 'Sborrowernotes',
relationship => 'SmyRelationship',
sex => 'F',
password => 'zerzerzer#',
flags => '666666',
userid => '98233',
opacnote => 'SmyOpacnote',
contactnote => 'SmyContactnote',
sort1 => 'SmySort1',
sort2 => 'SmySort2',
altcontactfirstname => 'SmyAltcontactfirstname',
altcontactsurname => 'SmyAltcontactsurname',
altcontactaddress1 => 'SmyAltcontactaddress1',
altcontactaddress2 => 'SmyAltcontactaddress2',
altcontactaddress3 => 'SmyAltcontactaddress3',
altcontactstate => 'SmyAltcontactstate',
altcontactzipcode => '565843',
altcontactcountry => 'SmyOtherCountry',
altcontactphone => 'SmyOtherphone',
smsalertnumber => '0683027347',
privacy => '667789'
}
);
is( $patron->borrowernumber, '12346', 'borrowernumber field set ok' );
is( $patron->cardnumber, '1234567891', 'cardnumber field set ok' );
is( $patron->surname, 'SmySurname', 'surname field set ok' );
is( $patron->firstname, 'SmyFirstname', 'firstname field set ok' );
is( $patron->title, 'Mme.', 'title field set ok' );
is( $patron->othernames, 'SmyOthernames', 'othernames field set ok' );
is( $patron->initials, 'SS', 'initials field set ok' );
is( $patron->streetnumber, '200', 'streetnumber field set ok' );
is( $patron->streettype, 'Rue', 'streettype field set ok' );
is( $patron->address, 'Smy personnal address', 'address field set ok' );
is( $patron->address2, 'Smy adress2', 'address2 field set ok' );
is( $patron->city, 'Lyon', 'city field set ok' );
is( $patron->state, 'Smystate', 'state field set ok' );
is( $patron->zipcode, '69000', 'zipcode field set ok' );
is( $patron->country, 'France', 'country field set ok' );
is( $patron->email, 'SmySurname.myFirstname@email.com', 'email field set ok' );
is( $patron->phone, '0402872935', 'phone field set ok' );
is( $patron->mobile, '0627884633', 'mobile field set ok' );
is( $patron->fax, '0402872936', 'fax field set ok' );
is( $patron->emailpro, 'SmyEmailPro@email.com', 'emailpro field set ok' );
is( $patron->phonepro, '0402873335', 'phonepro field set ok' );
is( $patron->B_streetnumber, '102', 'B_streetnumber field set ok' );
is( $patron->B_streettype, 'SmyB_streettype', 'B_streettype field set ok' );
is( $patron->B_address, 'SmyB_address', 'B_address field set ok' );
is( $patron->B_address2, 'SmyB_address2', 'B_address2 field set ok' );
is( $patron->B_city, 'SmyB_city', 'B_city field set ok' );
is( $patron->B_state, 'SmyB_state', 'B_state field set ok' );
is( $patron->B_zipcode, '12333', 'B_zipcode field set ok' );
is( $patron->B_country, 'SmyB_country', 'B_country field set ok' );
is( $patron->B_email, 'SmyB_email', 'B_email field set ok' );
is( $patron->B_phone, '0678353936', 'B_phone field set ok' );
is( $patron->dateofbirth, '1991-07-16', 'dateofbirth field set ok' );
is( $patron->branchcode, 'SmyBranCode', 'branchcode field set ok' );
is( $patron->categorycode, 'SmyCatCode', 'categorycode field set ok' );
is( $patron->dateenrolled, '2014-03-19', 'dateenrolled field set ok' );
is( $patron->dateexpiry, '2017-03-19', 'dateexpiry field set ok' );
is( $patron->gonenoaddress, '1', 'gonenoaddress field set ok' );
is( $patron->lost, '1', 'lost field set ok' );
is( $patron->debarred, '2016-04-19', 'debarred field set ok' );
is( $patron->debarredcomment, 'You are still debarred', 'debarredcomment field set ok' );
is( $patron->contactname, 'SmyContactname', 'contactname field set ok' );
is( $patron->contactfirstname, 'SmyContactfirstname', 'contactfirstname field set ok' );
is( $patron->contacttitle, 'SmyContacttitle', 'contacttitle field set ok' );
is( $patron->guarantorid, '223454321', 'guarantorid field set ok' );
is( $patron->borrowernotes, 'Sborrowernotes', 'borrowernotes field set ok' );
is( $patron->relationship, 'SmyRelationship', 'relationship field set ok' );
is( $patron->sex, 'F', 'sex field set ok' );
is( $patron->password, 'zerzerzer#', 'password field set ok' );
is( $patron->flags, '666666', 'flags field set ok' );
is( $patron->userid, '98233', 'userid field set ok' );
is( $patron->opacnote, 'SmyOpacnote', 'opacnote field set ok' );
is( $patron->contactnote, 'SmyContactnote', 'contactnote field set ok' );
is( $patron->sort1, 'SmySort1', 'sort1 field set ok' );
is( $patron->sort2, 'SmySort2', 'sort2 field set ok' );
is( $patron->altcontactfirstname, 'SmyAltcontactfirstname', 'altcontactfirstname field set ok' );
is( $patron->altcontactsurname, 'SmyAltcontactsurname', 'altcontactsurname field set ok' );
is( $patron->altcontactaddress1, 'SmyAltcontactaddress1', 'altcontactaddress1 field set ok' );
is( $patron->altcontactaddress2, 'SmyAltcontactaddress2', 'altcontactaddress2 field set ok' );
is( $patron->altcontactaddress3, 'SmyAltcontactaddress3', 'altcontactaddress3 field set ok' );
is( $patron->altcontactstate, 'SmyAltcontactstate', 'altcontactstate field set ok' );
is( $patron->altcontactzipcode, '565843', 'altcontactzipcode field set ok' );
is( $patron->altcontactcountry, 'SmyOtherCountry', 'altcontactcountry field set ok' );
is( $patron->altcontactphone, 'SmyOtherphone', 'altcontactphone field set ok' );
is( $patron->smsalertnumber, '0683027347', 'smsalertnumber field set ok' );
is( $patron->privacy, '667789', 'privacy field set ok' );
};
1;

View File

@ -27,7 +27,7 @@ use t::lib::TestBuilder;
BEGIN {
use_ok('C4::Accounts');
use_ok('Koha::Object');
use_ok('Koha::Borrower');
use_ok('Koha::Patron');
use_ok('Data::Dumper');
}
@ -107,7 +107,7 @@ my @test_data = (
{ amount => -5 , days_ago => $days + 1 , description =>'purge_zero_balance_fees should not delete fees with negative amout owed after threshold day' , delete => 0 }
);
my $borrower = Koha::Borrower->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => 'MPL' } )->store();
my $borrower = Koha::Patron->new( { firstname => 'Test', surname => 'Patron', categorycode => 'PT', branchcode => 'MPL' } )->store();
for my $data ( @test_data ) {
$sth->execute($borrower->borrowernumber, $data->{amount}, $data->{days_ago}, $data->{description});
@ -144,7 +144,7 @@ subtest "recordpayment() tests" => sub {
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
my $borrower = Koha::Borrower->new( {
my $borrower = Koha::Patron->new( {
cardnumber => '1234567890',
surname => 'McFly',
firstname => 'Marty',

View File

@ -21,7 +21,7 @@ use C4::Context;
use C4::Biblio qw( AddBiblio );
use Koha::Database;
use Koha::Libraries;
use Koha::Borrowers;
use Koha::Patrons;
use Test::More tests => 4;
@ -35,7 +35,7 @@ my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my @branches = Koha::Libraries->search();
my $borrower = Koha::Borrowers->search()->next();
my $borrower = Koha::Patrons->search()->next();
my $biblio = MARC::Record->new();
$biblio->append_fields(

View File

@ -203,7 +203,7 @@ subtest 'Test StoreLastBorrower' => sub {
$item_object = Koha::Items->find( $item->{itemnumber} );
$patron_object = $item_object->last_returned_by();
is( ref($patron_object), 'Koha::Borrower', 'Koha::Item::last_returned_by returned Koha::Borrower' );
is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' );
$patron = $builder->build(
{
@ -234,7 +234,7 @@ subtest 'Test StoreLastBorrower' => sub {
value => { privacy => 1, }
}
);
$patron_object = Koha::Borrowers->find( $patron->{borrowernumber} );
$patron_object = Koha::Patrons->find( $patron->{borrowernumber} );
$item_object->last_returned_by($patron_object);
$item_object = Koha::Items->find( $item->{itemnumber} );

View File

@ -12,7 +12,7 @@ use C4::Items qw( AddItem );
use C4::Members qw( AddMember GetMember );
use Koha::Database;
use Koha::DateUtils;
use Koha::Borrower::Debarments qw( GetDebarments DelDebarment );
use Koha::Patron::Debarments qw( GetDebarments DelDebarment );
use t::lib::TestBuilder;

View File

@ -29,7 +29,7 @@ BEGIN {
use_ok('C4::Creators::Lib');
use_ok('C4::Biblio');
use_ok('C4::Context');
use_ok('Koha::Borrower');
use_ok('Koha::Patron');
use_ok('MARC::Record');
}

View File

@ -20,8 +20,8 @@ use Modern::Perl;
use C4::Context;
use C4::Biblio qw( AddBiblio );
use Koha::Database;
use Koha::Borrowers;
use Koha::Libraries;
use Koha::Patrons;
use Koha::Item;
use Koha::DateUtils;
@ -36,7 +36,7 @@ my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
my @branches = Koha::Libraries->search();
my $borrower = Koha::Borrowers->search()->next();
my $borrower = Koha::Patrons->search()->next();
my $biblio = MARC::Record->new();
my $title = 'Silence in the library';

View File

@ -6,7 +6,7 @@ use Test::More tests => 14;
use C4::Context;
use C4::Members;
use Koha::Borrower::Modifications;
use Koha::Patron::Modifications;
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
@ -15,11 +15,11 @@ $dbh->{AutoCommit} = 0;
$dbh->do("DELETE FROM borrower_modifications");
## Create new pending modification
Koha::Borrower::Modifications->new( verification_token => '1234567890' )
Koha::Patron::Modifications->new( verification_token => '1234567890' )
->AddModifications( { surname => 'Hall', firstname => 'Kyle' } );
## Get the new pending modification
my $borrower = Koha::Borrower::Modifications->GetModifications(
my $borrower = Koha::Patron::Modifications->GetModifications(
{ verification_token => '1234567890' } );
## Verify we get the same data
@ -28,65 +28,65 @@ ok( $borrower->{'surname'} = 'Hall',
## Check the Verify method
ok(
Koha::Borrower::Modifications->Verify('1234567890'),
Koha::Patron::Modifications->Verify('1234567890'),
'Test that Verify() succeeds with a valid token'
);
## Delete the pending modification
$borrower = Koha::Borrower::Modifications->DelModifications(
$borrower = Koha::Patron::Modifications->DelModifications(
{ verification_token => '1234567890' } );
## Verify it's no longer in the database
$borrower = Koha::Borrower::Modifications->GetModifications(
$borrower = Koha::Patron::Modifications->GetModifications(
{ verification_token => '1234567890' } );
ok( !defined( $borrower->{'surname'} ), 'Test DelModifications()' );
## Check the Verify method
ok(
!Koha::Borrower::Modifications->Verify('1234567890'),
!Koha::Patron::Modifications->Verify('1234567890'),
'Test that Verify() method fails for a bad token'
);
## Create new pending modification, but for an existing borrower
Koha::Borrower::Modifications->new( borrowernumber => '2' )
Koha::Patron::Modifications->new( borrowernumber => '2' )
->AddModifications( { surname => 'Hall', firstname => 'Kyle' } );
## Test the counter
ok( Koha::Borrower::Modifications->GetPendingModificationsCount() == 1,
ok( Koha::Patron::Modifications->GetPendingModificationsCount() == 1,
'Test GetPendingModificationsCount()' );
## Create new pending modification for another existing borrower
Koha::Borrower::Modifications->new( borrowernumber => '3' )
Koha::Patron::Modifications->new( borrowernumber => '3' )
->AddModifications( { surname => 'Smith', firstname => 'Sandy' } );
## Test the counter
ok(
Koha::Borrower::Modifications->GetPendingModificationsCount() == 2,
Koha::Patron::Modifications->GetPendingModificationsCount() == 2,
'Add a new pending modification and test GetPendingModificationsCount() again'
);
## Check GetPendingModifications
my $pendings = Koha::Borrower::Modifications->GetPendingModifications();
my $pendings = Koha::Patron::Modifications->GetPendingModifications();
my @firstnames_mod = sort ( $pendings->[0]->{firstname}, $pendings->[1]->{firstname} );
ok( $firstnames_mod[0] eq 'Kyle', 'Test GetPendingModifications()' );
ok( $firstnames_mod[1] eq 'Sandy', 'Test GetPendingModifications() again' );
## This should delete the row from the table
Koha::Borrower::Modifications->DenyModifications('3');
Koha::Patron::Modifications->DenyModifications('3');
## Test the counter
ok( Koha::Borrower::Modifications->GetPendingModificationsCount() == 1,
ok( Koha::Patron::Modifications->GetPendingModificationsCount() == 1,
'Test DenyModifications()' );
## Save a copy of the borrowers original data
my $old_borrower = GetMember( borrowernumber => '2' );
## Apply the modifications
Koha::Borrower::Modifications->ApproveModifications('2');
Koha::Patron::Modifications->ApproveModifications('2');
## Test the counter
ok(
Koha::Borrower::Modifications->GetPendingModificationsCount() == 0,
Koha::Patron::Modifications->GetPendingModificationsCount() == 0,
'Test ApproveModifications() removes pending modification from db'
);
@ -98,7 +98,7 @@ ok( $new_borrower->{'surname'} eq 'Hall',
'Test ApproveModifications() applys modification to borrower' );
## Now let's put it back the way it was
Koha::Borrower::Modifications->new( borrowernumber => '2' )->AddModifications(
Koha::Patron::Modifications->new( borrowernumber => '2' )->AddModifications(
{
surname => $old_borrower->{'surname'},
firstname => $old_borrower->{'firstname'}
@ -106,15 +106,15 @@ Koha::Borrower::Modifications->new( borrowernumber => '2' )->AddModifications(
);
## Test the counter
ok( Koha::Borrower::Modifications->GetPendingModificationsCount() == 1,
ok( Koha::Patron::Modifications->GetPendingModificationsCount() == 1,
'Test GetPendingModificationsCount()' );
## Apply the modifications
Koha::Borrower::Modifications->ApproveModifications('2');
Koha::Patron::Modifications->ApproveModifications('2');
## Test the counter
ok(
Koha::Borrower::Modifications->GetPendingModificationsCount() == 0,
Koha::Patron::Modifications->GetPendingModificationsCount() == 0,
'Test ApproveModifications() removes pending modification from db, again'
);

View File

@ -25,7 +25,7 @@ use Koha::Database;
BEGIN {
use_ok('Koha::Object');
use_ok('Koha::Borrower');
use_ok('Koha::Patron');
}
my $schema = Koha::Database->new->schema;
@ -34,7 +34,7 @@ $schema->storage->txn_begin;
my $categorycode = $schema->resultset('Category')->first()->categorycode();
my $branchcode = $schema->resultset('Branch')->first()->branchcode();
my $object = Koha::Borrower->new();
my $object = Koha::Patron->new();
is( $object->in_storage, 0, "Object is not in storage" );
@ -47,8 +47,8 @@ is( $object->in_storage, 1, "Object is now stored" );
my $borrowernumber = $object->borrowernumber;
my $borrower = $schema->resultset('Borrower')->find( $borrowernumber );
is( $borrower->surname(), "Test Surname", "Object found in database" );
my $patron = $schema->resultset('Borrower')->find( $borrowernumber );
is( $patron->surname(), "Test Surname", "Object found in database" );
is( $object->is_changed(), 0, "Object is unchanged" );
$object->surname("Test Surname");
@ -65,8 +65,8 @@ $object->store();
is( $object->is_changed(), 0, "Object no longer marked as changed after being stored" );
$object->delete();
$borrower = $schema->resultset('Borrower')->find( $borrowernumber );
ok( ! $borrower, "Object no longer found in database" );
$patron = $schema->resultset('Borrower')->find( $borrowernumber );
ok( ! $patron, "Object no longer found in database" );
is( $object->in_storage, 0, "Object is not in storage" );
1;

View File

@ -10,7 +10,7 @@ use t::lib::TestBuilder;
use Test::More tests => 31;
use_ok('Koha::Borrower::Debarments');
use_ok('Koha::Patron::Debarments');
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
@ -65,9 +65,9 @@ $debarments = GetDebarments({ borrowernumber => $borrowernumber });
is( $debarments->[1]->{'comment'}, 'Test 3', "ModDebarment functions correctly" );
my $borrower = GetMember( borrowernumber => $borrowernumber );
is( $borrower->{'debarred'}, '9999-06-10', "Field borrowers.debarred set correctly" );
is( $borrower->{'debarredcomment'}, "Test 1\nTest 3", "Field borrowers.debarredcomment set correctly" );
my $patron = GetMember( borrowernumber => $borrowernumber );
is( $patron->{'debarred'}, '9999-06-10', "Field borrowers.debarred set correctly" );
is( $patron->{'debarredcomment'}, "Test 1\nTest 3", "Field borrowers.debarredcomment set correctly" );
AddUniqueDebarment({

View File

@ -25,7 +25,7 @@ use C4::Context;
use C4::Items qw( AddItem );
use C4::Members qw( AddMember GetMember );
use Koha::Borrower::Discharge;
use Koha::Patron::Discharge;
use Koha::Database;
use t::lib::TestBuilder;
@ -47,19 +47,19 @@ my $another_library = $builder->build({
C4::Context->_new_userenv('xxx');
C4::Context->set_userenv(0, 0, 0, 'firstname', 'surname', $library->{branchcode}, $library->{branchcode}, '', '', '', '', '');
my $borrower = $builder->build({
my $patron = $builder->build({
source => 'Borrower',
value => {
branchcode => $library->{branchcode},
}
});
my $borrower2 = $builder->build({
my $patron2 = $builder->build({
source => 'Borrower',
value => {
branchcode => $library->{branchcode},
}
});
my $borrower3 = $builder->build({
my $patron3 = $builder->build({
source => 'Borrower',
value => {
branchcode => $another_library->{branchcode},
@ -70,50 +70,50 @@ my $borrower3 = $builder->build({
my ( $biblionumber ) = AddBiblio( MARC::Record->new, '');
my $barcode = 'BARCODE42';
my ( undef, undef, $itemnumber ) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, barcode => $barcode }, $biblionumber);
AddIssue( $borrower, $barcode );
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrower->{borrowernumber} }), 0, 'A patron with issues cannot be discharged' );
AddIssue( $patron, $barcode );
is( Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->{borrowernumber} }), 0, 'A patron with issues cannot be discharged' );
is( Koha::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} }), undef, 'No request done if patron has issues' );
is( Koha::Borrower::Discharge::discharge({ borrowernumber => $borrower->{borrowernumber} }), undef, 'No discharge done if patron has issues' );
is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request' );
is_deeply( Koha::Borrower::Discharge::get_validated(), [], 'There is no validated discharge' );
is( Koha::Patron::Discharge::request({ borrowernumber => $patron->{borrowernumber} }), undef, 'No request done if patron has issues' );
is( Koha::Patron::Discharge::discharge({ borrowernumber => $patron->{borrowernumber} }), undef, 'No discharge done if patron has issues' );
is_deeply( Koha::Patron::Discharge::get_pendings(), [], 'There is no pending discharge request' );
is_deeply( Koha::Patron::Discharge::get_validated(), [], 'There is no validated discharge' );
AddReturn( $barcode );
# Discharge possible without issue
is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrower->{borrowernumber} }), 1, 'A patron without issues can be discharged' );
is( Koha::Patron::Discharge::can_be_discharged({ borrowernumber => $patron->{borrowernumber} }), 1, 'A patron without issues can be discharged' );
is(Koha::Borrower::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number");
is(Koha::Patron::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number");
# Verify that the user is not discharged anymore if the restriction has been lifted
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower->{borrowernumber} } );
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower2->{borrowernumber} } );
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower3->{borrowernumber} } );
is( Koha::Borrower::Discharge::is_discharged( { borrowernumber => $borrower->{borrowernumber} } ), 1, 'The patron has been discharged' );
is( Koha::Borrower::Debarments::IsDebarred( $borrower->{borrowernumber} ), '9999-12-31', 'The patron has been debarred after discharge' );
is( scalar( @{ Koha::Borrower::Discharge::get_validated() } ), 3, 'There are 3 validated discharges' );
is( scalar( @{ Koha::Borrower::Discharge::get_validated( { borrowernumber => $borrower->{borrowernumber} } ) } ), 1, 'There is 1 validated discharge for a given patron' );
is( scalar( @{ Koha::Borrower::Discharge::get_validated( { branchcode => $library->{branchcode} } ) } ), 2, 'There is 2 validated discharges for a given branchcode' ); # This is not used in the code yet
Koha::Borrower::Debarments::DelUniqueDebarment( { 'borrowernumber' => $borrower->{borrowernumber}, 'type' => 'DISCHARGE' } );
ok( !Koha::Borrower::Debarments::IsDebarred( $borrower->{borrowernumber} ), 'The debarment has been lifted' );
ok( !Koha::Borrower::Discharge::is_discharged( { borrowernumber => $borrower->{borrowernumber} } ), 'The patron is not discharged after the restriction has been lifted' );
Koha::Patron::Discharge::discharge( { borrowernumber => $patron->{borrowernumber} } );
Koha::Patron::Discharge::discharge( { borrowernumber => $patron2->{borrowernumber} } );
Koha::Patron::Discharge::discharge( { borrowernumber => $patron3->{borrowernumber} } );
is( Koha::Patron::Discharge::is_discharged( { borrowernumber => $patron->{borrowernumber} } ), 1, 'The patron has been discharged' );
is( Koha::Patron::Debarments::IsDebarred( $patron->{borrowernumber} ), '9999-12-31', 'The patron has been debarred after discharge' );
is( scalar( @{ Koha::Patron::Discharge::get_validated() } ), 3, 'There are 3 validated discharges' );
is( scalar( @{ Koha::Patron::Discharge::get_validated( { borrowernumber => $patron->{borrowernumber} } ) } ), 1, 'There is 1 validated discharge for a given patron' );
is( scalar( @{ Koha::Patron::Discharge::get_validated( { branchcode => $library->{branchcode} } ) } ), 2, 'There is 2 validated discharges for a given branchcode' ); # This is not used in the code yet
Koha::Patron::Debarments::DelUniqueDebarment( { 'borrowernumber' => $patron->{borrowernumber}, 'type' => 'DISCHARGE' } );
ok( !Koha::Patron::Debarments::IsDebarred( $patron->{borrowernumber} ), 'The debarment has been lifted' );
ok( !Koha::Patron::Discharge::is_discharged( { borrowernumber => $patron->{borrowernumber} } ), 'The patron is not discharged after the restriction has been lifted' );
# Verify that the discharge works multiple times
Koha::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} });
is(scalar( @{ Koha::Borrower::Discharge::get_pendings() }), 1, 'There is a pending discharge request (second time)');
Koha::Borrower::Discharge::discharge( { borrowernumber => $borrower->{borrowernumber} } );
is_deeply( Koha::Borrower::Discharge::get_pendings(), [], 'There is no pending discharge request (second time)');
Koha::Patron::Discharge::request({ borrowernumber => $patron->{borrowernumber} });
is(scalar( @{ Koha::Patron::Discharge::get_pendings() }), 1, 'There is a pending discharge request (second time)');
Koha::Patron::Discharge::discharge( { borrowernumber => $patron->{borrowernumber} } );
is_deeply( Koha::Patron::Discharge::get_pendings(), [], 'There is no pending discharge request (second time)');
# Check if PDF::FromHTML is installed.
my $check = eval { require PDF::FromHTML; };
# Tests for if PDF::FromHTML is installed
if ($check) {
isnt( Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrower->{borrowernumber} }), undef, "Temporary PDF generated." );
isnt( Koha::Patron::Discharge::generate_as_pdf({ borrowernumber => $patron->{borrowernumber} }), undef, "Temporary PDF generated." );
}
# Tests for if PDF::FromHTML is not installed
else {
warning_like { Koha::Borrower::Discharge::generate_as_pdf({ borrowernumber => $borrower->{borrowernumber}, testing => 1 }) }
warning_like { Koha::Patron::Discharge::generate_as_pdf({ borrowernumber => $patron->{borrowernumber}, testing => 1 }) }
[ qr/Can't locate PDF\/FromHTML.pm in \@INC/ ],
"Expected failure because of missing PDF::FromHTML.";
}
@ -126,7 +126,7 @@ else {
# Even if we switch off this flag, the connection will be blocked.
# The error is:
# DBIx::Class::ResultSet::create(): DBI Exception: DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction [for Statement "INSERT INTO discharges ( borrower, needed, validated) VALUES ( ?, ?, ? )" with ParamValues: 0='121', 1='2014-01-08T16:38:29', 2=undef] at /home/koha/src/Koha/DataObject/Discharge.pm line 33
#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $borrower->{borrowernumber} }), 1, 'Discharge request sent' );
#is( Koha::Service::Borrower::Discharge::request({ borrowernumber => $patron->{borrowernumber} }), 1, 'Discharge request sent' );
$schema->storage->txn_rollback;

View File

@ -27,7 +27,7 @@ use t::lib::TestBuilder;
use Test::More tests => 23;
use_ok('Koha::Borrower::Files');
use_ok('Koha::Patron::Files');
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
@ -49,7 +49,7 @@ my $borrowernumber = AddMember(
branchcode => $library->{branchcode},
);
my $bf = Koha::Borrower::Files->new(
my $bf = Koha::Patron::Files->new(
borrowernumber => $borrowernumber,
);

View File

@ -25,7 +25,7 @@ use Koha::Database;
BEGIN {
use_ok('Koha::Objects');
use_ok('Koha::Borrowers');
use_ok('Koha::Patrons');
}
# Start transaction
@ -41,7 +41,7 @@ my $categorycode =
my $branchcode =
Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
my $b1 = Koha::Borrower->new(
my $b1 = Koha::Patron->new(
{
surname => 'Test 1',
branchcode => $branchcode,
@ -49,7 +49,7 @@ my $b1 = Koha::Borrower->new(
}
);
$b1->store();
my $b2 = Koha::Borrower->new(
my $b2 = Koha::Patron->new(
{
surname => 'Test 2',
branchcode => $branchcode,
@ -57,7 +57,7 @@ my $b2 = Koha::Borrower->new(
}
);
$b2->store();
my $b3 = Koha::Borrower->new(
my $b3 = Koha::Patron->new(
{
surname => 'Test 3',
branchcode => $branchcode,
@ -66,31 +66,31 @@ my $b3 = Koha::Borrower->new(
);
$b3->store();
my $b1_new = Koha::Borrowers->find( $b1->borrowernumber() );
is( $b1->surname(), $b1_new->surname(), "Found matching borrower" );
my $b1_new = Koha::Patrons->find( $b1->borrowernumber() );
is( $b1->surname(), $b1_new->surname(), "Found matching patron" );
my @borrowers = Koha::Borrowers->search( { branchcode => $branchcode } );
is( @borrowers, 3, "Found 3 borrowers with Search" );
my @patrons = Koha::Patrons->search( { branchcode => $branchcode } );
is( @patrons, 3, "Found 3 patrons with Search" );
my $unexistent = Koha::Borrowers->find( '1234567890' );
my $unexistent = Koha::Patrons->find( '1234567890' );
is( $unexistent, undef, 'Koha::Objects->Find should return undef if the record does not exist' );
my $borrowers = Koha::Borrowers->search( { branchcode => $branchcode } );
is( $borrowers->count( { branchcode => $branchcode } ), 3, "Counted 3 borrowers with Count" );
my $patrons = Koha::Patrons->search( { branchcode => $branchcode } );
is( $patrons->count( { branchcode => $branchcode } ), 3, "Counted 3 patrons with Count" );
my $b = $borrowers->next();
is( $b->surname(), 'Test 1', "Next returns first borrower" );
$b = $borrowers->next();
is( $b->surname(), 'Test 2', "Next returns second borrower" );
$b = $borrowers->next();
is( $b->surname(), 'Test 3', "Next returns third borrower" );
$b = $borrowers->next();
my $b = $patrons->next();
is( $b->surname(), 'Test 1', "Next returns first patron" );
$b = $patrons->next();
is( $b->surname(), 'Test 2', "Next returns second patron" );
$b = $patrons->next();
is( $b->surname(), 'Test 3', "Next returns third patron" );
$b = $patrons->next();
is( $b, undef, "Next returns undef" );
# Test Reset and iteration in concert
$borrowers->reset();
foreach my $b ( $borrowers->as_list() ) {
is( $b->categorycode(), $categorycode, "Iteration returns a borrower object" );
$patrons->reset();
foreach my $b ( $patrons->as_list() ) {
is( $b->categorycode(), $categorycode, "Iteration returns a patron object" );
}
1;

View File

@ -27,7 +27,7 @@ use Time::Piece;
BEGIN {
use_ok('C4::Biblio');
use_ok('C4::Review');
use_ok('Koha::Borrower');
use_ok('Koha::Patron');
use_ok('MARC::Record');
}
@ -59,7 +59,7 @@ my $builder = t::lib::TestBuilder->new;
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
my $b1 = Koha::Borrower->new(
my $b1 = Koha::Patron->new(
{ surname => 'Borrower 1',
branchcode => $branchcode,
categorycode => $categorycode
@ -67,7 +67,7 @@ my $b1 = Koha::Borrower->new(
);
$b1->store();
my $b2 = Koha::Borrower->new(
my $b2 = Koha::Patron->new(
{ surname => 'Borrower 2',
branchcode => $branchcode,
categorycode => $categorycode
@ -75,7 +75,7 @@ my $b2 = Koha::Borrower->new(
);
$b2->store();
my $b3 = Koha::Borrower->new(
my $b3 = Koha::Patron->new(
{ surname => 'Borrower 3',
branchcode => $branchcode,
categorycode => $categorycode

View File

@ -25,7 +25,7 @@ use C4::Auth;
use C4::Context;
use Koha::Database;
use Koha::Borrower;
use Koha::Patron;
my $builder = t::lib::TestBuilder->new();

View File

@ -47,7 +47,7 @@ use C4::Members::AttributeTypes;
use C4::Members::Messaging;
use C4::Reports::Guided;
use C4::Templates;
use Koha::Borrower::Debarments;
use Koha::Patron::Debarments;
use Koha::DateUtils;
use Text::CSV;