|
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 => 177; |
21 |
use Test::More tests => 178; |
| 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 1233-1238
subtest 'test update_dateexpiry when no dateexpiry in file' => sub {
Link Here
|
| 1233 |
|
1233 |
|
| 1234 |
}; |
1234 |
}; |
| 1235 |
|
1235 |
|
|
|
1236 |
subtest 'prevent regression in update of dateexpiry with no date related flags' => sub { |
| 1237 |
# If the --update-expiration or --expiration-from-today flgas are not passed, the behaviour should be as foolows: |
| 1238 |
# 1) dateexpiry column is blank - preserve existing patron expiry date |
| 1239 |
# 2) dateexpiry column has a date value - update expiry date to match this new date |
| 1240 |
plan tests => 2; |
| 1241 |
|
| 1242 |
my $csv_headers = 'cardnumber,surname,branchcode,categorycode,dateenrolled,dateexpiry'; |
| 1243 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1244 |
$patron->dateexpiry( '2099-12-31' ); |
| 1245 |
$patron->dateenrolled( dt_from_string->add( months => '-24', end_of_month => 'limit' ) )->store; |
| 1246 |
my $csv_values = join( |
| 1247 |
',', $patron->cardnumber, $patron->surname, $patron->branchcode, $patron->categorycode, |
| 1248 |
$patron->dateenrolled, '' |
| 1249 |
); |
| 1250 |
|
| 1251 |
my $filename_1 = make_csv( $temp_dir, $csv_headers, $csv_values ); |
| 1252 |
open( my $handle_1, "<", $filename_1 ) or die "cannot open < $filename_1: $!"; |
| 1253 |
my $params = { file => $handle_1, matchpoint => 'cardnumber', overwrite_cardnumber => 1 }; |
| 1254 |
my $result = $patrons_import->import_patrons( $params, {} ); |
| 1255 |
$patron->discard_changes(); |
| 1256 |
|
| 1257 |
is( |
| 1258 |
$patron->dateexpiry, '2099-12-31', |
| 1259 |
'No expiry date provided in CSV so the existing patron expiry date is preserved' |
| 1260 |
); |
| 1261 |
|
| 1262 |
$csv_values = join( |
| 1263 |
',', $patron->cardnumber, $patron->surname, $patron->branchcode, $patron->categorycode, |
| 1264 |
$patron->dateenrolled, '2098-01-01' |
| 1265 |
); |
| 1266 |
|
| 1267 |
$filename_1 = make_csv( $temp_dir, $csv_headers, $csv_values ); |
| 1268 |
open( $handle_1, "<", $filename_1 ) or die "cannot open < $filename_1: $!"; |
| 1269 |
$params = { file => $handle_1, matchpoint => 'cardnumber', overwrite_cardnumber => 1 }; |
| 1270 |
$result = $patrons_import->import_patrons( $params, {} ); |
| 1271 |
$patron->discard_changes(); |
| 1272 |
|
| 1273 |
is( |
| 1274 |
$patron->dateexpiry, '2098-01-01', |
| 1275 |
'Expiry date updated to match the date provided in the CSV file' |
| 1276 |
); |
| 1277 |
}; |
| 1278 |
|
| 1279 |
|
| 1236 |
# got is { code => $code, attribute => $attribute } |
1280 |
# got is { code => $code, attribute => $attribute } |
| 1237 |
# expected is { $code => \@attributes } |
1281 |
# expected is { $code => \@attributes } |
| 1238 |
sub compare_patron_attributes { |
1282 |
sub compare_patron_attributes { |
| 1239 |
- |
|
|