Lines 18-24
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use Test::More tests => 142; |
21 |
use Test::More tests => 155; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
24 |
# To be replaced by t::lib::Mock |
24 |
# To be replaced by t::lib::Mock |
Lines 201-226
is($result_3b->{overwritten}, 0, 'Got the expected 0 overwritten result from imp
Link Here
|
201 |
|
201 |
|
202 |
# Given ... a new input and mocked C4::Context |
202 |
# Given ... a new input and mocked C4::Context |
203 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); |
203 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); |
|
|
204 |
my $attribute = $builder->build({ source => "BorrowerAttributeType"}); |
204 |
|
205 |
|
205 |
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'; |
206 |
my $csv_headers_a = '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,patron_attributes'; |
206 |
my $filename_4 = make_csv($temp_dir, $csv_headers, $new_input_line); |
207 |
my $res_header_a = '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, patron_attributes'; |
|
|
208 |
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,'.$attribute->{code}.':1'; |
209 |
my $filename_4 = make_csv($temp_dir, $csv_headers_a, $new_input_line); |
207 |
open(my $handle_4, "<", $filename_4) or die "cannot open < $filename_4: $!"; |
210 |
open(my $handle_4, "<", $filename_4) or die "cannot open < $filename_4: $!"; |
208 |
my $params_4 = { file => $handle_4, matchpoint => 'SHOW_BCODE', }; |
211 |
my $params_4 = { file => $handle_4, matchpoint => $attribute->{code}, }; |
209 |
|
212 |
|
210 |
# When ... |
213 |
# When ... |
211 |
my $result_4 = $patrons_import->import_patrons($params_4); |
214 |
my $result_4 = $patrons_import->import_patrons($params_4); |
212 |
|
215 |
|
213 |
# Then ... |
216 |
# Then ... |
|
|
217 |
warn Data::Dumper::Dumper( $result_4 ); |
214 |
is($result_4->{already_in_db}, 0, 'Got the expected 0 already_in_db from import_patrons with extended user'); |
218 |
is($result_4->{already_in_db}, 0, 'Got the expected 0 already_in_db from import_patrons with extended user'); |
215 |
is(scalar @{$result_4->{errors}}, 0, 'Got the expected 0 size error array from import_patrons with extended user'); |
219 |
is(scalar @{$result_4->{errors}}, 0, 'Got the expected 0 size error array from import_patrons with extended user'); |
216 |
|
220 |
|
217 |
is($result_4->{feedback}->[0]->{feedback}, 1, 'Got the expected 1 feedback from import_patrons with extended user'); |
221 |
is($result_4->{feedback}->[0]->{feedback}, 1, 'Got the expected 1 feedback from import_patrons with extended user'); |
218 |
is($result_4->{feedback}->[0]->{name}, 'headerrow', 'Got the expected header row name from import_patrons with extended user'); |
222 |
is($result_4->{feedback}->[0]->{name}, 'headerrow', 'Got the expected header row name from import_patrons with extended user'); |
219 |
is($result_4->{feedback}->[0]->{value}, $res_header, 'Got the expected header row value from import_patrons with extended user'); |
223 |
is($result_4->{feedback}->[0]->{value}, $res_header_a, 'Got the expected header row value from import_patrons with extended user'); |
220 |
|
224 |
|
221 |
is($result_4->{feedback}->[1]->{feedback}, 1, 'Got the expected second feedback from import_patrons with extended user'); |
225 |
is($result_4->{feedback}->[1]->{feedback}, 1, 'Got the expected second feedback from import_patrons with extended user'); |
222 |
is($result_4->{feedback}->[1]->{name}, 'attribute string', 'Got the expected attribute string from import_patrons with extended user'); |
226 |
is($result_4->{feedback}->[1]->{name}, 'attribute string', 'Got the expected attribute string from import_patrons with extended user'); |
223 |
is($result_4->{feedback}->[1]->{value}, '', 'Got the expected second feedback value from import_patrons with extended user'); |
227 |
is($result_4->{feedback}->[1]->{value}, $attribute->{code}.':1', 'Got the expected second feedback value from import_patrons with extended user'); |
224 |
|
228 |
|
225 |
is($result_4->{feedback}->[2]->{feedback}, 1, 'Got the expected third feedback from import_patrons with extended user'); |
229 |
is($result_4->{feedback}->[2]->{feedback}, 1, 'Got the expected third feedback from import_patrons with extended user'); |
226 |
is($result_4->{feedback}->[2]->{name}, 'lastimported', 'Got the expected last imported name from import_patrons with extended user'); |
230 |
is($result_4->{feedback}->[2]->{name}, 'lastimported', 'Got the expected last imported name from import_patrons with extended user'); |
Lines 230-235
is($result_4->{imported}, 1, 'Got the expected 1 imported result from import_pat
Link Here
|
230 |
is($result_4->{invalid}, 0, 'Got the expected 0 invalid result from import_patrons with extended user'); |
234 |
is($result_4->{invalid}, 0, 'Got the expected 0 invalid result from import_patrons with extended user'); |
231 |
is($result_4->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with extended user'); |
235 |
is($result_4->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with extended user'); |
232 |
|
236 |
|
|
|
237 |
seek $handle_4,0,0; #Reset to verify finding a matched patron works |
238 |
my $result_4a = $patrons_import->import_patrons($params_4); |
239 |
warn Data::Dumper::Dumper( $result_4a ); |
240 |
is($result_4a->{already_in_db}, 1, 'Got the expected 1 already_in_db from import_patrons with extended user matched'); |
241 |
is(scalar @{$result_4->{errors}}, 0, 'Got the expected 0 size error array from import_patrons with extended user matched'); |
242 |
|
243 |
is($result_4a->{feedback}->[0]->{feedback}, 1, 'Got the expected 1 feedback from import_patrons with extended user matched'); |
244 |
is($result_4a->{feedback}->[0]->{name}, 'headerrow', 'Got the expected header row name from import_patrons with extended user matched'); |
245 |
is($result_4a->{feedback}->[0]->{value}, $res_header_a, 'Got the expected header row value from import_patrons with extended user matched'); |
246 |
|
247 |
is($result_4a->{feedback}->[1]->{feedback}, 1, 'Got the expected second feedback from import_patrons with extended user matched'); |
248 |
is($result_4a->{feedback}->[1]->{name}, 'attribute string', 'Got the expected attribute string from import_patrons with extended user matched'); |
249 |
is($result_4a->{feedback}->[1]->{value}, $attribute->{code}.':1', 'Got the expected second feedback value from import_patrons with extended user matched'); |
250 |
|
251 |
is($result_4a->{feedback}->[2]->{already_in_db}, '1', 'Got the expected already_in_db from import_patrons with extended user matched'); |
252 |
like($result_4a->{feedback}->[2]->{value}, qr/^Donna \/ \d+/, 'Got the expected third feedback value from import_patrons with extended user matched'); |
253 |
|
254 |
is($result_4a->{imported}, 0, 'Got the expected 0 imported result from import_patrons with extended user matched'); |
255 |
is($result_4a->{invalid}, 0, 'Got the expected 0 invalid result from import_patrons with extended user matched'); |
256 |
is($result_4a->{overwritten}, 0, 'Got the expected 0 overwritten result from import_patrons with extended user matched'); |
257 |
|
233 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); |
258 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); |
234 |
|
259 |
|
235 |
# Given ... 3 new inputs. One with no branch code, one with unexpected branch code. |
260 |
# Given ... 3 new inputs. One with no branch code, one with unexpected branch code. |
236 |
- |
|
|