From 63a2408acd8db6501c3303dfae9b0b344a94d352 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) Enabling ILL and installing FreeForm by running: bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) 2) Run the script for ILL requests: misc/devel/create_test_data.pl -n 5 -s Illrequest -d backend=FreeForm 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 --- misc/devel/create_test_data.pl | 12 +++++++----- t/lib/TestBuilder.pm | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/misc/devel/create_test_data.pl b/misc/devel/create_test_data.pl index 9cebdfb3cc2..17202acceda 100755 --- a/misc/devel/create_test_data.pl +++ b/misc/devel/create_test_data.pl @@ -45,11 +45,13 @@ pod2usage(1) if $help || !$number || !$source; for ( 1 .. $number ) { - if ( $source eq 'Biblio' ) { - $builder->build_sample_biblio($values); - } elsif ( $source eq 'Item' ) { - $builder->build_sample_item($values); - } else { + if($source eq 'Biblio'){ + $builder->build_sample_biblio( $values ) + }elsif($source eq 'Item'){ + $builder->build_sample_item( $values ) + }elsif($source eq 'Illrequest'){ + $builder->build_sample_ill_request( $values ) + }else{ $builder->build( { source => $source, diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 57506b11d78..f7779ba031d 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -210,6 +210,21 @@ sub build_sample_item { )->store->get_from_storage; } +sub build_sample_ill_request { + my ( $self, $args ) = @_; + + $args->{biblio_id} = $args->{biblio_id} || $self->build_sample_biblio->biblionumber; + $args->{backend} = $args->{backend} || 'FreeForm'; + $args->{branchcode} = $args->{branchcode} || $self->build_object( { class => 'Koha::Libraries' } )->branchcode; + + return $self->build( + { + source => 'Illrequest', + value => $args, + } + ); +} + # ------------------------------------------------------------------------------ # Internal helper routines -- 2.30.2