From 7102e935edfa5300cb52e519098ca48e38fa16ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Sat, 11 Jun 2022 10:50:41 +0000 Subject: [PATCH] Bug 30947: Add test for Illrequest checkout with custom due date To test: 1) prove t/db_dependent/Illrequests.t --- t/db_dependent/Illrequests.t | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t index 5f4f25cdcc..bade08a92f 100755 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Illrequests.t @@ -41,7 +41,7 @@ use Test::Exception; use Test::Deep qw/ cmp_deeply ignore /; use Test::Warn; -use Test::More tests => 13; +use Test::More tests => 14; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; @@ -1178,6 +1178,43 @@ subtest 'Checking out' => sub { $schema->storage->txn_rollback; }; +subtest 'Checking out with custom due date' => sub { + plan tests => 1; + $schema->storage->txn_begin; + + my $library = $builder->build_object({ class => 'Koha::Libraries' }); + my $patron = $builder->build_object({ + class => 'Koha::Patrons', + value => { category_type => 'x' } + }); + my $biblio = $builder->build_sample_biblio(); + my $itemtype_loanable = $builder->build_object({ + class => 'Koha::ItemTypes', + value => { + notforloan => 0 + } + }); + my $request = $builder->build_object({ + class => 'Koha::Illrequests', + value => { + borrowernumber => $patron->borrowernumber, + biblio_id => $biblio->biblionumber + } + }); + + t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode }); + my $duedate = '2099-05-21 00:00:00'; + my $form_stage_loanable = $request->check_out({ + stage => 'form', + item_type => $itemtype_loanable->itemtype, + branchcode => $library->branchcode, + duedate => $duedate + }); + is($patron->checkouts->next->date_due, $duedate, "Custom due date was used"); + + $schema->storage->txn_rollback; +}; + subtest 'Checking Limits' => sub { plan tests => 30; -- 2.30.2