Lines 19-26
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use Test::More tests => 122; |
21 |
use Test::More tests => 122; |
22 |
use Test::MockModule; |
|
|
23 |
|
22 |
|
|
|
23 |
# To be replaced by t::lib::Mock |
24 |
use Test::MockModule; |
24 |
use Koha::Database; |
25 |
use Koha::Database; |
25 |
|
26 |
|
26 |
use File::Temp qw(tempfile tempdir); |
27 |
use File::Temp qw(tempfile tempdir); |
Lines 73-78
my $result_0 = $patrons_import->import_patrons($params_0);
Link Here
|
73 |
is($result_0, undef, 'Got the expected undef from import_patrons with no file handle'); |
74 |
is($result_0, undef, 'Got the expected undef from import_patrons with no file handle'); |
74 |
|
75 |
|
75 |
# Given ... a file handle to file with headers only. |
76 |
# Given ... a file handle to file with headers only. |
|
|
77 |
my $ExtendedPatronAttributes = 0; |
78 |
my $context = Test::MockModule->new('C4::Context'); # Necessary mocking for consistent test results. |
79 |
$context->mock('preference', sub { my ($mod, $meth) = @_; |
80 |
if ( $meth eq 'ExtendedPatronAttributes' ) { return $ExtendedPatronAttributes; } |
81 |
if ( $meth eq 'dateformat' ) { return 'us'; } |
82 |
}); |
83 |
|
84 |
|
76 |
my $csv_headers = 'cardnumber,surname,firstname,title,othernames,initials,streetnumber,streettype,address,address2,city,state,zipcode,country,email,phone,mobile,fax,dateofbirth,branchcode,categorycode,dateenrolled,dateexpiry,userid,password'; |
85 |
my $csv_headers = 'cardnumber,surname,firstname,title,othernames,initials,streetnumber,streettype,address,address2,city,state,zipcode,country,email,phone,mobile,fax,dateofbirth,branchcode,categorycode,dateenrolled,dateexpiry,userid,password'; |
77 |
my $res_header = 'cardnumber, surname, firstname, title, othernames, initials, streetnumber, streettype, address, address2, city, state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode, categorycode, dateenrolled, dateexpiry, userid, password'; |
86 |
my $res_header = 'cardnumber, surname, firstname, title, othernames, initials, streetnumber, streettype, address, address2, city, state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode, categorycode, dateenrolled, dateexpiry, userid, password'; |
78 |
my $csv_one_line = '1000,Nancy,Jenkins,Dr,,NJ,78,Circle,Bunting,El Paso,Henderson,Texas,79984,United States,ajenkins0@sourceforge.net,7-(388)559-6763,3-(373)151-4471,8-(509)286-4001,10/16/1965,CPL,PT,12/28/2014,07/01/2015,jjenkins0,DPQILy'; |
87 |
my $csv_one_line = '1000,Nancy,Jenkins,Dr,,NJ,78,Circle,Bunting,El Paso,Henderson,Texas,79984,United States,ajenkins0@sourceforge.net,7-(388)559-6763,3-(373)151-4471,8-(509)286-4001,10/16/1965,CPL,PT,12/28/2014,07/01/2015,jjenkins0,DPQILy'; |
Lines 144-154
is($result_3->{invalid}, 1, 'Got the expected 1 invalid result from import_patro
Link Here
|
144 |
is($result_3->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with duplicate userid'); |
153 |
is($result_3->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with duplicate userid'); |
145 |
|
154 |
|
146 |
# Given ... a new input and mocked C4::Context |
155 |
# Given ... a new input and mocked C4::Context |
147 |
my $context = Test::MockModule->new('C4::Context'); |
156 |
$ExtendedPatronAttributes = 1; # Updates mocked C4::Preferences result. |
148 |
$context->mock('preference', sub { my ($mod, $meth) = @_; |
|
|
149 |
if ( $meth eq 'ExtendedPatronAttributes' ) { return 1; } |
150 |
if ( $meth eq 'dateformat' ) { return 'us'; } |
151 |
}); |
152 |
|
157 |
|
153 |
my $new_input_line = '1001,Donna,Sullivan,Mrs,Henry,DS,59,Court,Burrows,Reading,Salt Lake City,Pennsylvania,19605,United States,hsullivan1@purevolume.com,3-(864)009-3006,7-(291)885-8423,1-(879)095-5038,09/19/1970,LPL,PT,03/04/2015,07/01/2015,hsullivan1,8j6P6Dmap'; |
158 |
my $new_input_line = '1001,Donna,Sullivan,Mrs,Henry,DS,59,Court,Burrows,Reading,Salt Lake City,Pennsylvania,19605,United States,hsullivan1@purevolume.com,3-(864)009-3006,7-(291)885-8423,1-(879)095-5038,09/19/1970,LPL,PT,03/04/2015,07/01/2015,hsullivan1,8j6P6Dmap'; |
154 |
my $filename_4 = make_csv($temp_dir, $csv_headers, $new_input_line); |
159 |
my $filename_4 = make_csv($temp_dir, $csv_headers, $new_input_line); |
155 |
- |
|
|