From 26988f0b4ed276b16d44b8bf1fdbf78c9af05357 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 24 Jul 2024 13:45:05 +0000 Subject: [PATCH] Bug 37448: Add build_sample_ill_request The linked biblio_id of a generated test ILL request needs to be created by build_sample_biblio->AddBiblio. Or else the related biblio is created by just 'build' and is not indexed + its related metadata is missing. To test: 1) Apply the [DONT PUSH] patch and enable ILLModule 2) Run the script for ILL requests: misc/devel/create_test_data.pl -n 5 -s Illrequest -d backend=Standard 3) Visit the ILLModule: http:///cgi-bin/koha/ill/ill-requests.pl 4) Notice it loads 5 test ILL requests correctly Signed-off-by: Pedro Amorim Signed-off-by: Kyle M Hall --- t/lib/TestBuilder.pm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index dc38cd5ae9..5aa1d0cdb7 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -210,6 +210,40 @@ sub build_sample_item { )->store->get_from_storage; } +=pod + +=head2 build_sample_ill_request + +Builds a sample ILL request with the supplied arguments. + +C<$args> is a hashref with the following optional keys: + +=over 4 + +=item * C (default: a new sample biblio created with L) + +=item * C (default: Standard) + +=item * C (default: a random branch) + +=back + +=cut +sub build_sample_ill_request { + my ( $self, $args ) = @_; + + $args->{biblio_id} = $args->{biblio_id} || $self->build_sample_biblio->biblionumber; + $args->{backend} = $args->{backend} || 'Standard'; + $args->{branchcode} = $args->{branchcode} || $self->build_object( { class => 'Koha::Libraries' } )->branchcode; + + return $self->build_object( + { + class => 'Koha::ILL::Requests', + value => $args, + } + )->store->get_from_storage; +} + # ------------------------------------------------------------------------------ # Internal helper routines -- 2.39.5