From 7b5578eb03f9a7b5c09921553a81991aa6fc7b53 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 2 Oct 2019 14:53:42 +0000 Subject: [PATCH] Bug 20816: Make SIP tests pass under ES --- t/db_dependent/SIP/Message.t | 17 ++++++++++------- t/db_dependent/SIP/Transaction.t | 21 ++++++++------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 2cdeba73d6..4ff440c0d2 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -317,11 +317,14 @@ sub test_checkin_v2 { my $card1 = $patron1->{cardnumber}; my $sip_patron1 = C4::SIP::ILS::Patron->new( $card1 ); $findpatron = $sip_patron1; - my $item = $builder->build({ - source => 'Item', - value => { damaged => 0, withdrawn => 0, itemlost => 0, restricted => 0, homebranch => $branchcode, holdingbranch => $branchcode }, + my $item_object = $builder->build_sample_item({ + damaged => 0, + withdrawn => 0, + itemlost => 0, + restricted => 0, + homebranch => $branchcode, + holdingbranch => $branchcode, }); - my $item_object = Koha::Items->find( $item->{itemnumber} ); my $mockILS = $mocks->{ils}; my $server = { ils => $mockILS, account => {} }; @@ -355,7 +358,7 @@ sub test_checkin_v2 { $siprequest = CHECKIN . 'N' . 'YYYYMMDDZZZZHHMMSS' . siprequestdate( $today->clone->add( days => 1) ) . FID_INST_ID . $branchcode . '|'. - FID_ITEM_ID . $item->{barcode} . '|' . + FID_ITEM_ID . $item_object->barcode . '|' . FID_TERMINAL_PWD . 'ignored' . '|'; undef $response; $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); @@ -434,7 +437,7 @@ sub test_checkin_v2 { $server->{account}->{ct_always_send} = 0; # Checkin at wrong branch: issue item and switch branch, and checkin - my $issue = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item->{itemnumber} })->store; + my $issue = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object->itemnumber })->store; $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); undef $response; @@ -443,7 +446,7 @@ sub test_checkin_v2 { is( substr($response,2,1), '0', 'OK flag is false when we check in at the wrong branch and we do not allow it' ); is( substr($response,5,1), 'Y', 'Alert flag is set' ); check_field( $respcode, $response, FID_SCREEN_MSG, 'Checkin failed', 'Check screen msg' ); - $branchcode = $item->{homebranch}; # switch back + $branchcode = $item_object->homebranch; # switch back t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); # Data corrupted: add same issue_id to old_issues diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index c6d2abd65f..c977684fa2 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -46,25 +46,20 @@ subtest fill_holds_at_checkout => sub { t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode}, flags => 1 }); my $itype = $builder->build({ source => 'Itemtype', value =>{notforloan=>0} }); - my $biblio = $builder->build({ source => 'Biblio' }); - my $biblioitem = $builder->build({ source => 'Biblioitem', value=>{biblionumber=>$biblio->{biblionumber}} }); - my $item1 = $builder->build({ source => 'Item', value => { + my $item1 = $builder->build_sample_item({ barcode => 'barcode4test', homebranch => $branch->{branchcode}, holdingbranch => $branch->{branchcode}, - biblionumber => $biblio->{biblionumber}, itype => $itype->{itemtype}, notforloan => 0, - } - }); - my $item2 = $builder->build({ source => 'Item', value => { + })->unblessed; + my $item2 = $builder->build_sample_item({ homebranch => $branch->{branchcode}, holdingbranch => $branch->{branchcode}, - biblionumber => $biblio->{biblionumber}, + biblionumber => $item1->{biblionumber}, itype => $itype->{itemtype}, notforloan => 0, - } - }); + })->unblessed; Koha::CirculationRules->set_rules( { @@ -85,18 +80,18 @@ subtest fill_holds_at_checkout => sub { { branchcode => $branch->{branchcode}, borrowernumber => $borrower->{borrowernumber}, - biblionumber => $biblio->{biblionumber} + biblionumber => $item1->{biblionumber} } ); my $reserve2 = AddReserve( { branchcode => $branch->{branchcode}, borrowernumber => $borrower->{borrowernumber}, - biblionumber => $biblio->{biblionumber} + biblionumber => $item1->{biblionumber} } ); - my $bib = Koha::Biblios->find( $biblio->{biblionumber} ); + my $bib = Koha::Biblios->find( $item1->{biblionumber} ); is( $bib->holds->count(), 2, "Bib has 2 holds"); my $sip_patron = C4::SIP::ILS::Patron->new( $borrower->{cardnumber} ); -- 2.11.0