Lines 28-33
use Koha::Database;
Link Here
|
28 |
use File::Temp qw(tempfile tempdir); |
28 |
use File::Temp qw(tempfile tempdir); |
29 |
my $temp_dir = tempdir('Koha_patrons_import_test_XXXX', CLEANUP => 1, TMPDIR => 1); |
29 |
my $temp_dir = tempdir('Koha_patrons_import_test_XXXX', CLEANUP => 1, TMPDIR => 1); |
30 |
|
30 |
|
|
|
31 |
use t::lib::Mocks; |
31 |
use t::lib::TestBuilder; |
32 |
use t::lib::TestBuilder; |
32 |
my $builder = t::lib::TestBuilder->new; |
33 |
my $builder = t::lib::TestBuilder->new; |
33 |
|
34 |
|
Lines 81-92
warning_is { $result_0 = $patrons_import->import_patrons($params_0) }
Link Here
|
81 |
is($result_0, undef, 'Got the expected undef from import_patrons with no file handle'); |
82 |
is($result_0, undef, 'Got the expected undef from import_patrons with no file handle'); |
82 |
|
83 |
|
83 |
# Given ... a file handle to file with headers only. |
84 |
# Given ... a file handle to file with headers only. |
84 |
my $ExtendedPatronAttributes = 0; |
85 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); |
85 |
my $context = Test::MockModule->new('C4::Context'); # Necessary mocking for consistent test results. |
86 |
t::lib::Mocks::mock_preference('dateformat', 'us'); |
86 |
$context->mock('preference', sub { my ($mod, $meth) = @_; |
|
|
87 |
if ( $meth eq 'ExtendedPatronAttributes' ) { return $ExtendedPatronAttributes; } |
88 |
if ( $meth eq 'dateformat' ) { return 'us'; } |
89 |
}); |
90 |
|
87 |
|
91 |
|
88 |
|
92 |
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'; |
89 |
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'; |
Lines 160-166
is($result_3->{invalid}, 1, 'Got the expected 1 invalid result from import_patro
Link Here
|
160 |
is($result_3->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with duplicate userid'); |
157 |
is($result_3->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with duplicate userid'); |
161 |
|
158 |
|
162 |
# Given ... a new input and mocked C4::Context |
159 |
# Given ... a new input and mocked C4::Context |
163 |
$ExtendedPatronAttributes = 1; # Updates mocked C4::Preferences result. |
160 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); |
164 |
|
161 |
|
165 |
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'; |
162 |
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'; |
166 |
my $filename_4 = make_csv($temp_dir, $csv_headers, $new_input_line); |
163 |
my $filename_4 = make_csv($temp_dir, $csv_headers, $new_input_line); |
Lines 190-196
is($result_4->{imported}, 1, 'Got the expected 1 imported result from import_pat
Link Here
|
190 |
is($result_4->{invalid}, 0, 'Got the expected 0 invalid result from import_patrons with extended user'); |
187 |
is($result_4->{invalid}, 0, 'Got the expected 0 invalid result from import_patrons with extended user'); |
191 |
is($result_4->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with extended user'); |
188 |
is($result_4->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with extended user'); |
192 |
|
189 |
|
193 |
$context->unmock('preference'); |
190 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); |
194 |
|
191 |
|
195 |
# Given ... 3 new inputs. One with no branch code, one with unexpected branch code. |
192 |
# Given ... 3 new inputs. One with no branch code, one with unexpected branch code. |
196 |
my $input_no_branch = '1002,Johnny,Reynolds,Mr,Patricia,JR,12,Hill,Kennedy,Saint Louis,Colorado Springs,Missouri,63131,United States,preynolds2@washington.edu,7-(925)314-9514,0-(315)973-8956,4-(510)556-2323,09/18/1967,,PT,05/07/2015,07/01/2015,preynolds2,K3HiDzl'; |
193 |
my $input_no_branch = '1002,Johnny,Reynolds,Mr,Patricia,JR,12,Hill,Kennedy,Saint Louis,Colorado Springs,Missouri,63131,United States,preynolds2@washington.edu,7-(925)314-9514,0-(315)973-8956,4-(510)556-2323,09/18/1967,,PT,05/07/2015,07/01/2015,preynolds2,K3HiDzl'; |
197 |
- |
|
|