From d1f824430a4d3d059ba7461aa2e257e5c2613d1d Mon Sep 17 00:00:00 2001 From: Slava Shishkin Date: Mon, 25 Apr 2022 15:16:48 +0300 Subject: [PATCH] Bug 28269: Add tests for Acquisitions Orders search by ISSN also with SearchWithISSNVariations on and off Signed-off-by: KIT Library Germany Signed-off-by: Katrin Fischer --- t/db_dependent/Acquisition.t | 54 ++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index ae8855d7b7..d824c4d78f 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -475,10 +475,6 @@ is( scalar( @$orders ), 1, 'GetHistory returns correctly a search for internalno $orders = GetHistory( vendornote => 'vendor note foo' ); is( scalar( @$orders ), 1, 'GetHistory returns correctly a search for vendornote' ); - -# Test GetHistory() with and without SearchWithISBNVariations -# The ISBN passed as a param is the ISBN-10 version of the 13-digit ISBN in the sample record declared in $marcxml - my $budgetid2 = C4::Budgets::AddBudget( { budget_code => "budget_code_test_modrecv", @@ -616,16 +612,53 @@ sub run_flavoured_tests { is( scalar(@$orders), 1, "GetHistory searches correctly by ISBN" ); Koha::Acquisition::Orders->find($ordernumber)->cancel; + + my $marc_record_issn = MARC::Record->new; + $marc_record_issn->append_fields( create_issn_field( '2434561X', $marcflavour ) ); + my ( $biblionumber6_issn, undef ) = AddBiblio( $marc_record_issn, '' ); + + my $orders_issn = GetHistory( issn => '2434561X' ); + is( scalar(@$orders_issn), 0, "Precheck that ISSN shouln't be in database" ); + + # Create order + my $ordernumber_issn = Koha::Acquisition::Order->new( { + basketno => $basketno, + biblionumber => $biblionumber6_issn, + budget_id => $budget->{budget_id}, + order_internalnote => "internal note", + order_vendornote => "vendor note", + quantity => 1, + ecost => 10, + rrp => 10, + listprice => 10, + ecost => 10, + rrp => 10, + discount => 0, + uncertainprice => 0, + } )->store->ordernumber; + + t::lib::Mocks::mock_preference('SearchWithISSNVariations', 0); + $orders_issn = GetHistory( issn => '2434-561X' ); + is( scalar(@$orders_issn), 0, "GetHistory searches correctly by ISSN" ); + + t::lib::Mocks::mock_preference('SearchWithISSNVariations', 1); + $orders_issn = GetHistory( issn => '2434-561X' ); + is( scalar(@$orders_issn), 1, "GetHistory searches correctly by ISSN" ); + + Koha::Acquisition::Orders->find($ordernumber_issn)->cancel; } +# Test GetHistory() with and without SearchWithISBNVariations or SearchWithISSNVariations +# The ISBN passed as a param is the ISBN-10 version of the 13-digit ISBN in the sample record declared in $marcxml + # Do "flavoured" tests subtest 'MARC21' => sub { - plan tests => 2; + plan tests => 5; run_flavoured_tests('MARC21'); }; subtest 'UNIMARC' => sub { - plan tests => 2; + plan tests => 5; run_flavoured_tests('UNIMARC'); }; @@ -663,6 +696,15 @@ sub create_isbn_field { return $field; } +sub create_issn_field { + my ( $issn, $marcflavour ) = @_; + + my ( $issn_field, $issn_subfield ) = get_issn_field(); + my $field = MARC::Field->new( $issn_field, '', '', $issn_subfield => $issn ); + + return $field; +} + subtest 'ModReceiveOrder replacementprice tests' => sub { plan tests => 2; #Let's build an order, we need a couple things though -- 2.30.2