From df38651e633bdbb5548dc8ec7bfe8682bb9bbcaf Mon Sep 17 00:00:00 2001 From: Eric Garcia Date: Tue, 6 Aug 2024 19:06:45 +0000 Subject: [PATCH] Bug 33641: Unit Tests --- .../Circulation/MarkIssueReturned.t | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t index 9c43132a25..a744e1a5d5 100755 --- a/t/db_dependent/Circulation/MarkIssueReturned.t +++ b/t/db_dependent/Circulation/MarkIssueReturned.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::Exception; use t::lib::Mocks; @@ -304,3 +304,33 @@ subtest 'AutoRemoveOverduesRestrictions' => sub { $schema->storage->txn_rollback; }; + +subtest 'Pass return_branch to old_issues' => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => { category_type => 'P', enrolmentfee => 0 } } ); + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron = $builder->build_object( + { class => 'Koha::Patrons', + value => { branchcode => $library->branchcode, categorycode => $category->categorycode } + } + ); + my $item = $builder->build_sample_item( + { + library => $library->branchcode, + } + ); + + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); + + my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); + my $issue_id = C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item->itemnumber ); + + is( $issue_id, $issue->issue_id, 'Item has been returned' ); + my $old_issue = Koha::Old::Checkouts->find( $issue_id ); + is( $old_issue->return_branch, $library->branchcode, 'Return branch is passed correctly' ); + + $schema->storage->txn_rollback +}; -- 2.30.2