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 => 173; |
21 |
use Test::More tests => 175; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Encode qw( encode_utf8 ); |
24 |
use Encode qw( encode_utf8 ); |
Lines 28-33
use utf8;
Link Here
|
28 |
use Test::MockModule; |
28 |
use Test::MockModule; |
29 |
use Koha::Database; |
29 |
use Koha::Database; |
30 |
use Koha::Patron::Relationships; |
30 |
use Koha::Patron::Relationships; |
|
|
31 |
use Koha::DateUtils qw(dt_from_string); |
31 |
|
32 |
|
32 |
use File::Temp qw(tempfile tempdir); |
33 |
use File::Temp qw(tempfile tempdir); |
33 |
my $temp_dir = tempdir('Koha_patrons_import_test_XXXX', CLEANUP => 1, TMPDIR => 1); |
34 |
my $temp_dir = tempdir('Koha_patrons_import_test_XXXX', CLEANUP => 1, TMPDIR => 1); |
Lines 189-195
is($result_3a->{overwritten}, 1, 'Got the expected 1 overwritten result from imp
Link Here
|
189 |
# overwrite but firstname is not |
190 |
# overwrite but firstname is not |
190 |
my $filename_3c = make_csv($temp_dir, $csv_headers, $csv_one_line_b); |
191 |
my $filename_3c = make_csv($temp_dir, $csv_headers, $csv_one_line_b); |
191 |
open(my $handle_3c, "<", $filename_3c) or die "cannot open < $filename_3: $!"; |
192 |
open(my $handle_3c, "<", $filename_3c) or die "cannot open < $filename_3: $!"; |
192 |
my $params_3c = { file => $handle_3c, matchpoint => 'cardnumber', overwrite_cardnumber => 1, preserve_fields => [ 'firstname' ] }; |
193 |
my $params_3c = { file => $handle_3c, matchpoint => 'cardnumber', overwrite_cardnumber => 1, preserve_fields => [ 'firstname' ], update_dateexpiry => 1, update_dateexpiry_from_today => 1 }; |
|
|
194 |
|
195 |
my $patron_3 = Koha::Patrons->find({ cardnumber => '1000' }); |
196 |
is( $patron_3->dateexpiry, '2015-07-01', "Expiration date is correct with update_dateexpiry = false" ); |
193 |
|
197 |
|
194 |
# When ... |
198 |
# When ... |
195 |
my $result_3c; |
199 |
my $result_3c; |
Lines 211-216
is($result_3c->{invalid}, 0, 'Got the expected 0 invalid result from import_patr
Link Here
|
211 |
is($result_3c->{overwritten}, 1, 'Got the expected 1 overwritten result from import_patrons that matched'); |
215 |
is($result_3c->{overwritten}, 1, 'Got the expected 1 overwritten result from import_patrons that matched'); |
212 |
|
216 |
|
213 |
my $patron_3c = Koha::Patrons->find({ cardnumber => '1000' }); |
217 |
my $patron_3c = Koha::Patrons->find({ cardnumber => '1000' }); |
|
|
218 |
is( $patron_3c->dateexpiry, dt_from_string->add( months => 99, end_of_month => 'limit' )->ymd, "Expiration date is correct with update_dateexpiry = true" ); |
219 |
|
214 |
is( $patron_3c->surname, "Nancy2", "Surname field is preserved from original" ); |
220 |
is( $patron_3c->surname, "Nancy2", "Surname field is preserved from original" ); |
215 |
is( $patron_3c->firstname, "Jenkins", "Firstname field is overwritten" ); |
221 |
is( $patron_3c->firstname, "Jenkins", "Firstname field is overwritten" ); |
216 |
|
222 |
|