Bugzilla – Attachment 156368 Details for
Bug 34883
Regression in Patron Import dateexpiry function
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34883: Add unit test
Bug-34883-Add-unit-test.patch (text/plain), 3.06 KB, created by
Matt Blenkinsop
on 2023-09-29 09:06:41 UTC
(
hide
)
Description:
Bug 34883: Add unit test
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2023-09-29 09:06:41 UTC
Size:
3.06 KB
patch
obsolete
>From dc216533be77c04f2fe9cb5e41d2ed3cbdc57c2b Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Fri, 29 Sep 2023 09:04:52 +0000 >Subject: [PATCH] Bug 34883: Add unit test > >prove -v t/db_dependent/Koha/Patrons/Import.t >--- > t/db_dependent/Koha/Patrons/Import.t | 46 +++++++++++++++++++++++++++- > 1 file changed, 45 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index 6bb4fde8b3f..9a33f8efcfe 100755 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 177; >+use Test::More tests => 178; > use Test::Warn; > use Test::Exception; > use Encode qw( encode_utf8 ); >@@ -1233,6 +1233,50 @@ subtest 'test update_dateexpiry when no dateexpiry in file' => sub { > > }; > >+subtest 'prevent regression in update of dateexpiry with no date related flags' => sub { >+ # If the --update-expiration or --expiration-from-today flgas are not passed, the behaviour should be as foolows: >+ # 1) dateexpiry column is blank - preserve existing patron expiry date >+ # 2) dateexpiry column has a date value - update expiry date to match this new date >+ plan tests => 2; >+ >+ my $csv_headers = 'cardnumber,surname,branchcode,categorycode,dateenrolled,dateexpiry'; >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ $patron->dateexpiry( '2099-12-31' ); >+ $patron->dateenrolled( dt_from_string->add( months => '-24', end_of_month => 'limit' ) )->store; >+ my $csv_values = join( >+ ',', $patron->cardnumber, $patron->surname, $patron->branchcode, $patron->categorycode, >+ $patron->dateenrolled, '' >+ ); >+ >+ my $filename_1 = make_csv( $temp_dir, $csv_headers, $csv_values ); >+ open( my $handle_1, "<", $filename_1 ) or die "cannot open < $filename_1: $!"; >+ my $params = { file => $handle_1, matchpoint => 'cardnumber', overwrite_cardnumber => 1 }; >+ my $result = $patrons_import->import_patrons( $params, {} ); >+ $patron->discard_changes(); >+ >+ is( >+ $patron->dateexpiry, '2099-12-31', >+ 'No expiry date provided in CSV so the existing patron expiry date is preserved' >+ ); >+ >+ $csv_values = join( >+ ',', $patron->cardnumber, $patron->surname, $patron->branchcode, $patron->categorycode, >+ $patron->dateenrolled, '2098-01-01' >+ ); >+ >+ $filename_1 = make_csv( $temp_dir, $csv_headers, $csv_values ); >+ open( $handle_1, "<", $filename_1 ) or die "cannot open < $filename_1: $!"; >+ $params = { file => $handle_1, matchpoint => 'cardnumber', overwrite_cardnumber => 1 }; >+ $result = $patrons_import->import_patrons( $params, {} ); >+ $patron->discard_changes(); >+ >+ is( >+ $patron->dateexpiry, '2098-01-01', >+ 'Expiry date updated to match the date provided in the CSV file' >+ ); >+}; >+ >+ > # got is { code => $code, attribute => $attribute } > # expected is { $code => \@attributes } > sub compare_patron_attributes { >-- >2.37.1 (Apple Git-137.1)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34883
:
156149
|
156196
|
156197
|
156368
|
156369
|
156370