Bugzilla – Attachment 142069 Details for
Bug 31095
Remove Koha::Patron::Debarment::GetDebarments and use $patron->restrictions in preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31095: Remove GetDebarments from Circulation.t
Bug-31095-Remove-GetDebarments-from-Circulationt.patch (text/plain), 9.19 KB, created by
Martin Renvoize (ashimema)
on 2022-10-18 14:09:19 UTC
(
hide
)
Description:
Bug 31095: Remove GetDebarments from Circulation.t
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-10-18 14:09:19 UTC
Size:
9.19 KB
patch
obsolete
>From 8d7339c95f6393d29d9e4fc6b38a981bc40d5043 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 25 Aug 2022 08:36:37 +0100 >Subject: [PATCH] Bug 31095: Remove GetDebarments from Circulation.t > >Replace GetDebarments with $patron->restrictions. > >Test plan >1. Run test prior to patch - all should pass >2. Run test after patch - all should pass >3. Confirm no tests were removed as part of the patch > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 73 ++++++++++++++++++++---------------- > 1 file changed, 40 insertions(+), 33 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index b12e1b27f0..c706439cae 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -46,7 +46,7 @@ use Koha::Items; > use Koha::Item::Transfers; > use Koha::Checkouts; > use Koha::Patrons; >-use Koha::Patron::Debarments qw( GetDebarments AddDebarment DelUniqueDebarment ); >+use Koha::Patron::Debarments qw( AddDebarment DelUniqueDebarment ); > use Koha::Holds; > use Koha::CirculationRules; > use Koha::Subscriptions; >@@ -90,19 +90,19 @@ sub test_debarment_on_checkout { > ); > my @caller = caller; > my $line_number = $caller[2]; >- AddIssue( $patron, $item->barcode, $due_date ); >+ AddIssue( $patron->unblessed, $item->barcode, $due_date ); > > my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); > is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) > or diag('AddReturn returned message ' . Dumper $message ); >- my $debarments = Koha::Patron::Debarments::GetDebarments( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >- is( scalar(@$debarments), 1, 'Test at line ' . $line_number ); >+ my $suspensions = $patron->restrictions->search({ type => 'SUSPENSION' } ); >+ is( $suspensions->count, 1, 'Test at line ' . $line_number ); > >- is( $debarments->[0]->{expiration}, >+ my $THE_suspension = $suspensions->next; >+ is( $THE_suspension->expiration, > $expected_expiration_date, 'Test at line ' . $line_number ); > Koha::Patron::Debarments::DelUniqueDebarment( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ { borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); > }; > > my $schema = Koha::Database->schema; >@@ -2508,7 +2508,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > plan tests => 8; > > my $library = $builder->build( { source => 'Branch' } ); >- my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); > > # Add 2 items > my $biblionumber = $builder->build_sample_biblio( >@@ -2549,15 +2549,15 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > my $now = dt_from_string; > my $five_days_ago = $now->clone->subtract( days => 5 ); > my $ten_days_ago = $now->clone->subtract( days => 10 ); >- AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue >- AddIssue( $patron, $item_2->barcode, $ten_days_ago ) >+ AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue >+ AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) > ; # Add another overdue > > t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); > AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); >- my $debarments = Koha::Patron::Debarments::GetDebarments( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >- is( scalar(@$debarments), 1 ); >+ my $suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); >+ is( $suspensions->count, 1, "Suspension added" ); >+ my $THE_suspension = $suspensions->next; > > # FIXME Is it right? I'd have expected 5 * 2 - 1 instead > # Same for the others >@@ -2568,12 +2568,13 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > dateonly => 1 > } > ); >- is( $debarments->[0]->{expiration}, $expected_expiration ); >+ is( $THE_suspension->expiration, $expected_expiration, "Suspesion expiration set" ); > > AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); >- $debarments = Koha::Patron::Debarments::GetDebarments( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >- is( scalar(@$debarments), 1 ); >+ $suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); >+ is( $suspensions->count, 1, "Only one suspension" ); >+ $THE_suspension = $suspensions->next; >+ > $expected_expiration = output_pref( > { > dt => $now->clone->add( days => ( 10 - 1 ) * 2 ), >@@ -2581,19 +2582,20 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > dateonly => 1 > } > ); >- is( $debarments->[0]->{expiration}, $expected_expiration ); >+ is( $THE_suspension->expiration, $expected_expiration, "Suspension expiration date updated" ); > > Koha::Patron::Debarments::DelUniqueDebarment( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >+ { borrowernumber => $patron->borrowernumber, type => 'SUSPENSION' } ); > > t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); >- AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue >- AddIssue( $patron, $item_2->barcode, $ten_days_ago ) >+ AddIssue( $patron->unblessed, $item_1->barcode, $five_days_ago ); # Add an overdue >+ AddIssue( $patron->unblessed, $item_2->barcode, $ten_days_ago ) > ; # Add another overdue > AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); >- $debarments = Koha::Patron::Debarments::GetDebarments( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >- is( scalar(@$debarments), 1 ); >+ $suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); >+ is( $suspensions->count, 1, "Only one suspension" ); >+ $THE_suspension = $suspensions->next; >+ > $expected_expiration = output_pref( > { > dt => $now->clone->add( days => ( 5 - 1 ) * 2 ), >@@ -2601,12 +2603,13 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > dateonly => 1 > } > ); >- is( $debarments->[0]->{expiration}, $expected_expiration ); >+ is( $THE_suspension->expiration, $expected_expiration, "Suspension expiration date updated" ); > > AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); >- $debarments = Koha::Patron::Debarments::GetDebarments( >- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); >- is( scalar(@$debarments), 1 ); >+ $suspensions = $patron->restrictions->search( { type => 'SUSPENSION' } ); >+ is( $suspensions->count, 1, "Only one suspension" ); >+ $THE_suspension = $suspensions->next; >+ > $expected_expiration = output_pref( > { > dt => $now->clone->add( days => ( 5 - 1 ) * 2 + ( 10 - 1 ) * 2 ), >@@ -2614,14 +2617,14 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > dateonly => 1 > } > ); >- is( $debarments->[0]->{expiration}, $expected_expiration ); >+ is( $THE_suspension->expiration, $expected_expiration, "Suspension expiration date updated" ); > }; > > subtest 'AddReturn + suspension_chargeperiod' => sub { > plan tests => 27; > > my $library = $builder->build( { source => 'Branch' } ); >- my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); > > my $biblionumber = $builder->build_sample_biblio( > { >@@ -2905,8 +2908,13 @@ subtest 'AddReturn | is_overdue' => sub { > t::lib::Mocks::mock_preference('MaxFine', '100'); > > my $library = $builder->build( { source => 'Branch' } ); >- my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); >- my $manager = $builder->build_object({ class => "Koha::Patrons" }); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { categorycode => $patron_category->{categorycode} } >+ } >+ ); >+ my $manager = $builder->build_object( { class => "Koha::Patrons" } ); > t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); > > my $item = $builder->build_sample_item( >@@ -2936,7 +2944,6 @@ subtest 'AddReturn | is_overdue' => sub { > my $two_days_ago = $now->clone->subtract( days => 2 ); > my $five_days_ago = $now->clone->subtract( days => 5 ); > my $ten_days_ago = $now->clone->subtract( days => 10 ); >- $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > > # No return date specified, today will be used => 10 days overdue charged > AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago >-- >2.20.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 31095
:
139614
|
139719
|
139720
|
139721
|
139722
|
139723
|
139724
|
139725
|
139726
|
139727
|
139728
|
139742
|
139743
|
139744
|
139745
|
139746
|
139747
|
139748
|
139749
|
139750
|
139751
|
139752
|
139753
|
139754
|
139755
|
139756
|
139757
|
139758
|
140714
|
140715
|
140716
|
140717
|
140718
|
140719
|
140720
|
140721
|
140722
|
140723
|
140724
|
140725
|
140726
|
140727
|
140728
|
140729
|
140730
|
140731
|
142059
|
142060
|
142061
|
142062
|
142063
|
142064
|
142065
|
142066
|
142067
|
142068
|
142069
|
142070
|
142071
|
142072
|
142073
|
142074
|
142075
|
142076
|
143745
|
143746
|
143747
|
143748
|
143749
|
143750
|
143751
|
143752
|
143753
|
143754
|
143755
|
143756
|
143757
|
143758
|
143759
|
143760
|
143761
|
143762
|
143763
|
144903
|
144904
|
144905
|
144906
|
144907
|
144908
|
144909
|
144910
|
144911
|
144912
|
144913
|
144914
|
144915
|
144916
|
144917
|
144918
|
144919
|
144920
|
144921
|
145800
|
145801
|
145803
|
145845