Bugzilla – Attachment 155066 Details for
Bug 34617
Patron expiration dates not updated during import when there is no dateexpiry column in the file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34617: Unit tests
Bug-34617-Unit-tests.patch (text/plain), 5.35 KB, created by
Marcel de Rooy
on 2023-09-01 08:26:48 UTC
(
hide
)
Description:
Bug 34617: Unit tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-09-01 08:26:48 UTC
Size:
5.35 KB
patch
obsolete
>From 489f767d4fd4ff5dff659ca90fd0f93b4be82e70 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 25 Aug 2023 14:51:23 +0000 >Subject: [PATCH] Bug 34617: Unit tests >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Koha/Patrons/Import.t | 66 ++++++++++++++++++++++++++-- > 1 file changed, 62 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index aaaf167213..6bb4fde8b3 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 => 176; >+use Test::More tests => 177; > use Test::Warn; > use Test::Exception; > use Encode qw( encode_utf8 ); >@@ -186,15 +186,15 @@ is($result_3a->{imported}, 0, 'Got the expected 0 imported result from import_pa > is($result_3a->{invalid}, 0, 'Got the expected 0 invalid result from import_patrons'); > is($result_3a->{overwritten}, 1, 'Got the expected 1 overwritten result from import_patrons that matched'); > >+my $patron_3 = Koha::Patrons->find({ cardnumber => '1000' }); >+is( $patron_3->dateexpiry, '2015-07-01', "Expiration date is correct with update_dateexpiry = false" ); >+ > # Given ... valid file handle, good matchpoint that matches should overwrite when set, surname is protected from > # overwrite but firstname is not > my $filename_3c = make_csv($temp_dir, $csv_headers, $csv_one_line_b); > open(my $handle_3c, "<", $filename_3c) or die "cannot open < $filename_3: $!"; > my $params_3c = { file => $handle_3c, matchpoint => 'cardnumber', overwrite_cardnumber => 1, preserve_fields => [ 'firstname' ], update_dateexpiry => 1, update_dateexpiry_from_today => 1 }; > >-my $patron_3 = Koha::Patrons->find({ cardnumber => '1000' }); >-is( $patron_3->dateexpiry, '2015-07-01', "Expiration date is correct with update_dateexpiry = false" ); >- > # When ... > my $result_3c; > warning_is { $result_3c = $patrons_import->import_patrons($params_3c) } >@@ -1175,6 +1175,64 @@ subtest 'welcome_email' => sub { > is($notices->count, 1, 'Notice was queued'); > }; > >+subtest 'test update_dateexpiry when no dateexpiry in file' => sub { >+ >+ # Normally, imports on ly update included columns, however, if we are asking Koha >+ # to calculate expiration dates >+ >+ plan tests => 3; >+ >+ my $csv_headers = 'cardnumber,surname,branchcode,categorycode,dateenrolled'; >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ $patron->dateexpiry( dt_from_string() ); >+ $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 >+ ); >+ $patron->category->enrolmentperiod(42)->enrolmentperioddate(undef)->store(); >+ >+ 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, update_dateexpiry => 1 }; >+ my $result = $patrons_import->import_patrons( $params, {} ); >+ >+ $patron->discard_changes(); >+ >+ is( >+ $patron->dateexpiry, dt_from_string->add( months => 18, end_of_month => 'limit' )->ymd, >+ "Expiration date is correct with update_dateexpiry = true no dateexpiry in file and update_datexpiryfromtoday false (i.e. use passed dateenrolled) " >+ ); >+ >+ $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, update_dateexpiry => 1, >+ update_dateexpiry_from_today => 1 >+ }; >+ $result = $patrons_import->import_patrons( $params, {} ); >+ $patron->discard_changes(); >+ is( >+ $patron->dateexpiry, dt_from_string->add( months => 42, end_of_month => 'limit' )->ymd, >+ "Expiration date is correct with update_dateexpiry = true no dateexpiry in file and update_datexpiryfromtoday true " >+ ); >+ >+ $csv_headers = 'cardnumber,surname,branchcode,categorycode'; >+ $csv_values = join( ',', $patron->cardnumber, $patron->surname, $patron->branchcode, $patron->categorycode ); >+ $filename_1 = make_csv( $temp_dir, $csv_headers, $csv_values ); >+ open( $handle_1, "<", $filename_1 ) or die "cannot open < $filename_1: $!"; >+ $patron->dateexpiry( dt_from_string() ); >+ $patron->dateenrolled( dt_from_string->add( months => '-24', end_of_month => 'limit' ) )->store; >+ $params = { file => $handle_1, matchpoint => 'cardnumber', overwrite_cardnumber => 1, update_dateexpiry => 1 }; >+ $result = $patrons_import->import_patrons( $params, {} ); >+ $patron->discard_changes(); >+ is( >+ $patron->dateexpiry, dt_from_string->add( months => 42, end_of_month => 'limit' )->ymd, >+ "Expiration date is correct with update_dateexpiry = true no dateexpiry in file and update_datexpiryfromtoday false but no dateenrolled in file (today is used) " >+ ); >+ >+}; >+ > # got is { code => $code, attribute => $attribute } > # expected is { $code => \@attributes } > sub compare_patron_attributes { >-- >2.30.2
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 34617
:
154816
|
154817
|
154867
|
154868
| 155066 |
155067