Bugzilla – Attachment 186162 Details for
Bug 9762
Log circulation overrides
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9762: (follow-up) Mock the user branch in NoIssuesChargeGuarantees.t and dateexpiry.t tests
Bug-9762-follow-up-Mock-the-user-branch-in-NoIssue.patch (text/plain), 2.65 KB, created by
Lucas Gass (lukeg)
on 2025-09-04 14:48:34 UTC
(
hide
)
Description:
Bug 9762: (follow-up) Mock the user branch in NoIssuesChargeGuarantees.t and dateexpiry.t tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-09-04 14:48:34 UTC
Size:
2.65 KB
patch
obsolete
>From 507d5325e30e800a6f164bd909bb835012e578f2 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 4 Sep 2025 14:46:21 +0000 >Subject: [PATCH] Bug 9762: (follow-up) Mock the user branch in > NoIssuesChargeGuarantees.t and dateexpiry.t tests > >Without the patch: > >t/db_dependent/Circulation/NoIssuesChargeGuarantees.t fails >t/db_dependent/Circulation/dateexpiry.t fails > >With the patch: > >t/db_dependent/Circulation/NoIssuesChargeGuarantees.t passes >t/db_dependent/Circulation/dateexpiry.t passes >--- > C4/Circulation.pm | 5 +++-- > t/db_dependent/Circulation/NoIssuesChargeGuarantees.t | 8 +++++++- > t/db_dependent/Circulation/dateexpiry.t | 9 +++++++++ > 3 files changed, 19 insertions(+), 3 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index cc36501f7f4..a03953b56e1 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1417,8 +1417,9 @@ sub CanBookBeIssued { > } > > my $borrower = $patron; >- my $user = C4::Context->userenv->{number}; >- my $branchcode = C4::Context->userenv->{branch}; >+ my $userenv = C4::Context->userenv; >+ my $user = $userenv ? $userenv->{number} : undef; >+ my $branchcode = $userenv ? $userenv->{branch} : undef; > > # action, cardnumber, barcode, date, heure, user, branche > if ($issueconfirmed) { >diff --git a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >index f8ed66d0c31..d3fe9815f95 100755 >--- a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >+++ b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >@@ -34,7 +34,13 @@ $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new(); > >-my $item = $builder->build_sample_item; >+my $item = $builder->build_sample_item; >+my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+t::lib::Mocks::mock_userenv( >+ { >+ branchcode => $library->branchcode, >+ } >+); > > my $patron_category = $builder->build( > { >diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t >index 8eb52d443dc..b52a711746d 100755 >--- a/t/db_dependent/Circulation/dateexpiry.t >+++ b/t/db_dependent/Circulation/dateexpiry.t >@@ -45,6 +45,15 @@ subtest 'Tests for CalcDateDue related to dateexpiry' => sub { > }; > > sub can_book_be_issued { >+ >+ #mock the user branch >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ t::lib::Mocks::mock_userenv( >+ { >+ branchcode => $library->branchcode, >+ } >+ ); >+ > my $item = $builder->build_sample_item; > my $patron = $builder->build_object( > { >-- >2.39.5
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 9762
:
149554
|
156222
|
163847
|
164022
|
164067
|
164068
|
164302
|
164387
|
164426
|
164479
|
164508
|
164509
|
164510
|
164519
|
170271
|
170272
|
170273
|
176742
|
177294
|
177295
|
177296
|
178029
|
178030
|
178031
|
178036
|
181303
|
181304
|
181305
|
181306
|
181307
|
181308
|
181340
|
181341
|
181342
|
181343
|
181344
|
181345
|
181346
|
181357
|
181358
|
181359
|
181360
|
181361
|
181362
|
181363
|
181371
|
181381
|
181390
|
181393
|
181545
|
181546
|
185118
|
185314
|
185315
|
185316
|
185317
|
185318
|
185319
|
185320
|
185321
|
185322
|
185323
|
185815
|
185816
|
185817
|
185818
|
185819
|
185820
|
185821
|
185822
|
185823
|
185824
|
185825
|
185826
|
185827
|
186149
|
186150
|
186162
|
186163