From 07ebb3cbe176a8cc1fef569d642bb443107c9da2 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 14 Sep 2023 13:59:42 -0400 Subject: [PATCH] Bug 34737: Tidy t/db_dependent/SIP/Transaction.t Signed-off-by: Toni Ford Signed-off-by: Kyle M Hall --- t/db_dependent/SIP/Transaction.t | 590 +++++++++++++++++-------------- 1 file changed, 328 insertions(+), 262 deletions(-) diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t index c979cc72572..54b77b2cdf5 100755 --- a/t/db_dependent/SIP/Transaction.t +++ b/t/db_dependent/SIP/Transaction.t @@ -26,45 +26,52 @@ use Koha::DateUtils qw( dt_from_string output_pref ); my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; -my $builder = t::lib::TestBuilder->new(); -my $borr1 = $builder->build({ source => 'Borrower' }); -my $card = $borr1->{cardnumber}; -my $sip_patron = C4::SIP::ILS::Patron->new( $card ); +my $builder = t::lib::TestBuilder->new(); +my $borr1 = $builder->build( { source => 'Borrower' } ); +my $card = $borr1->{cardnumber}; +my $sip_patron = C4::SIP::ILS::Patron->new($card); # Create transaction RenewAll, assign patron, and run (no items) my $transaction = C4::SIP::ILS::Transaction::RenewAll->new(); -is( ref $transaction, "C4::SIP::ILS::Transaction::RenewAll", "New transaction created" ); -is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" ); +is( ref $transaction, "C4::SIP::ILS::Transaction::RenewAll", "New transaction created" ); +is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); isnt( $transaction->do_renew_all, undef, "RenewAll on zero items" ); subtest fill_holds_at_checkout => sub { plan tests => 6; + my $category = $builder->build( { source => 'Category', value => { category_type => 'A' } } ); + my $branch = $builder->build( { source => 'Branch' } ); + my $borrower = $builder->build( + { + source => 'Borrower', + value => { + branchcode => $branch->{branchcode}, + categorycode => $category->{categorycode} + } + } + ); + t::lib::Mocks::mock_userenv( { branchcode => $branch->{branchcode}, flags => 1 } ); - my $category = $builder->build({ source => 'Category', value => { category_type => 'A' }}); - my $branch = $builder->build({ source => 'Branch' }); - my $borrower = $builder->build({ source => 'Borrower', value =>{ - branchcode => $branch->{branchcode}, - categorycode=>$category->{categorycode} + my $itype = $builder->build( { source => 'Itemtype', value => { notforloan => 0 } } ); + my $item1 = $builder->build_sample_item( + { + barcode => 'barcode4test', + homebranch => $branch->{branchcode}, + holdingbranch => $branch->{branchcode}, + itype => $itype->{itemtype}, + notforloan => 0, } - }); - t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode}, flags => 1 }); - - my $itype = $builder->build({ source => 'Itemtype', value =>{notforloan=>0} }); - my $item1 = $builder->build_sample_item({ - barcode => 'barcode4test', - homebranch => $branch->{branchcode}, - holdingbranch => $branch->{branchcode}, - itype => $itype->{itemtype}, - notforloan => 0, - })->unblessed; - my $item2 = $builder->build_sample_item({ - homebranch => $branch->{branchcode}, - holdingbranch => $branch->{branchcode}, - biblionumber => $item1->{biblionumber}, - itype => $itype->{itemtype}, - notforloan => 0, - })->unblessed; + )->unblessed; + my $item2 = $builder->build_sample_item( + { + homebranch => $branch->{branchcode}, + holdingbranch => $branch->{branchcode}, + biblionumber => $item1->{biblionumber}, + itype => $itype->{itemtype}, + notforloan => 0, + } + )->unblessed; Koha::CirculationRules->set_rules( { @@ -97,20 +104,20 @@ subtest fill_holds_at_checkout => sub { ); my $bib = Koha::Biblios->find( $item1->{biblionumber} ); - is( $bib->holds->count(), 2, "Bib has 2 holds"); + is( $bib->holds->count(), 2, "Bib has 2 holds" ); - my $sip_patron = C4::SIP::ILS::Patron->new( $borrower->{cardnumber} ); - my $sip_item = C4::SIP::ILS::Item->new( $item1->{barcode} ); + my $sip_patron = C4::SIP::ILS::Patron->new( $borrower->{cardnumber} ); + my $sip_item = C4::SIP::ILS::Item->new( $item1->{barcode} ); my $transaction = C4::SIP::ILS::Transaction::Checkout->new(); - is( ref $transaction, "C4::SIP::ILS::Transaction::Checkout", "New transaction created" ); - is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" ); - is( $transaction->item( $sip_item ), $sip_item, "Item assigned to transaction" ); + is( ref $transaction, "C4::SIP::ILS::Transaction::Checkout", "New transaction created" ); + is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); + is( $transaction->item($sip_item), $sip_item, "Item assigned to transaction" ); my $checkout = $transaction->do_checkout(); - use Data::Dumper; # Temporary debug statement - is( $bib->holds->count(), 1, "Bib has 1 holds remaining") or diag Dumper $checkout; + use Data::Dumper; # Temporary debug statement + is( $bib->holds->count(), 1, "Bib has 1 holds remaining" ) or diag Dumper $checkout; - t::lib::Mocks::mock_preference('itemBarcodeInputFilter', 'whitespace'); - $sip_item = C4::SIP::ILS::Item->new( ' barcode 4 test '); + t::lib::Mocks::mock_preference( 'itemBarcodeInputFilter', 'whitespace' ); + $sip_item = C4::SIP::ILS::Item->new(' barcode 4 test '); $transaction = C4::SIP::ILS::Transaction::Checkout->new(); is( $sip_item->{barcode}, $item1->{barcode}, "Item assigned to transaction" ); }; @@ -122,11 +129,9 @@ subtest "FeePayment->pay tests" => sub { # Create a borrower and add some outstanding debts to their account my $patron = $builder->build( { source => 'Borrower' } ); my $account = - Koha::Account->new( { patron_id => $patron->{borrowernumber} } ); - my $debt1 = $account->add_debit( - { type => 'ACCOUNT', amount => 100, interface => 'commandline' } ); - my $debt2 = $account->add_debit( - { type => 'ACCOUNT', amount => 200, interface => 'commandline' } ); + Koha::Account->new( { patron_id => $patron->{borrowernumber} } ); + my $debt1 = $account->add_debit( { type => 'ACCOUNT', amount => 100, interface => 'commandline' } ); + my $debt2 = $account->add_debit( { type => 'ACCOUNT', amount => 200, interface => 'commandline' } ); # Instantiate a new FeePayment transaction object my $trans = C4::SIP::ILS::Transaction::FeePayment->new(); @@ -139,16 +144,18 @@ subtest "FeePayment->pay tests" => sub { # Test the 'pay' method # FIXME: pay should not require a borrowernumber # (we should reach out to the transaction which should contain a patron object) - my $pay_type = '00'; # 00 - Cash, 01 - VISA, 02 - Creditcard - my $ok = - $trans->pay( $patron->{borrowernumber}, 100, $pay_type, $debt1->id, 0, - 0 ); + my $pay_type = '00'; # 00 - Cash, 01 - VISA, 02 - Creditcard + my $ok = $trans->pay( + $patron->{borrowernumber}, 100, $pay_type, $debt1->id, 0, + 0 + ); ok( $ok, "FeePayment transaction succeeded" ); $debt1->discard_changes; - is( $debt1->amountoutstanding + 0, 0, - "Debt1 was reduced to 0 as expected" ); - my $offsets = Koha::Account::Offsets->search( - { debit_id => $debt1->id, credit_id => { '!=' => undef } } ); + is( + $debt1->amountoutstanding + 0, 0, + "Debt1 was reduced to 0 as expected" + ); + my $offsets = Koha::Account::Offsets->search( { debit_id => $debt1->id, credit_id => { '!=' => undef } } ); is( $offsets->count, 1, "FeePayment produced an offset line correctly" ); my $credit = $offsets->next->credit; is( $credit->payment_type, 'SIP00', "Payment type was set correctly" ); @@ -157,8 +164,8 @@ subtest "FeePayment->pay tests" => sub { subtest cancel_hold => sub { plan tests => 7; - my $library = $builder->build_object ({ class => 'Koha::Libraries' }); - my $patron = $builder->build_object( + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { @@ -166,11 +173,13 @@ subtest cancel_hold => sub { } } ); - t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode, flags => 1 }); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); - my $item = $builder->build_sample_item({ - library => $library->branchcode, - }); + my $item = $builder->build_sample_item( + { + library => $library->branchcode, + } + ); Koha::CirculationRules->set_rules( { @@ -195,18 +204,18 @@ subtest cancel_hold => sub { itemnumber => $item->itemnumber, } ); - is( $item->biblio->holds->count(), 1, "Hold was placed on bib"); - is( $item->holds->count(),1,"Hold was placed on specific item"); + is( $item->biblio->holds->count(), 1, "Hold was placed on bib" ); + is( $item->holds->count(), 1, "Hold was placed on specific item" ); - my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); - my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); my $transaction = C4::SIP::ILS::Transaction::Hold->new(); - is( ref $transaction, "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); - is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" ); - is( $transaction->item( $sip_item ), $sip_item, "Item assigned to transaction" ); + is( ref $transaction, "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); + is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); + is( $transaction->item($sip_item), $sip_item, "Item assigned to transaction" ); my $hold = $transaction->drop_hold(); - is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining"); - is( $item->holds->count(), 0, "Item has 0 holds remaining"); + is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" ); + is( $item->holds->count(), 0, "Item has 0 holds remaining" ); }; subtest do_hold => sub { @@ -215,9 +224,7 @@ subtest do_hold => sub { my $library = $builder->build_object( { class => 'Koha::Libraries', - value => { - pickup_location => 1 - } + value => { pickup_location => 1 } } ); my $patron_1 = $builder->build_object( @@ -238,8 +245,7 @@ subtest do_hold => sub { } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { @@ -266,15 +272,19 @@ subtest do_hold => sub { "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); - is( $transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); my $hold = $transaction->do_hold(); is( $item->biblio->holds->count(), 2, "Bib has 2 holds" ); my $THE_hold = $patron_2->holds->next; - is( $THE_hold->priority, 2, 'Hold placed from SIP should have a correct priority of 2'); + is( $THE_hold->priority, 2, 'Hold placed from SIP should have a correct priority of 2' ); is( $THE_hold->branchcode, $patron_2->branchcode, 'Hold placed from SIP should have the branchcode set' ); }; @@ -284,9 +294,7 @@ subtest "Placing holds via SIP check CanItemBeReserved" => sub { my $library = $builder->build_object( { class => 'Koha::Libraries', - value => { - pickup_location => 0 - } + value => { pickup_location => 0 } } ); my $patron_1 = $builder->build_object( @@ -307,8 +315,7 @@ subtest "Placing holds via SIP check CanItemBeReserved" => sub { } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { @@ -324,10 +331,14 @@ subtest "Placing holds via SIP check CanItemBeReserved" => sub { "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); - is( $transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); my $hold = $transaction->do_hold(); is( $transaction->ok, 0, "Hold was not allowed" ); @@ -336,11 +347,11 @@ subtest "Placing holds via SIP check CanItemBeReserved" => sub { subtest do_checkin => sub { plan tests => 13; - my $mockILS = Test::MockObject->new; - my $server = { ils => $mockILS }; - my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $mockILS = Test::MockObject->new; + my $server = { ils => $mockILS }; + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); - my $patron = $builder->build_object( + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { @@ -349,8 +360,7 @@ subtest do_checkin => sub { } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { @@ -358,36 +368,43 @@ subtest do_checkin => sub { } ); - # Checkout - my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); - my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new(); - is( $co_transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $co_transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $co_transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $co_transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); my $checkout = $co_transaction->do_checkout(); - is( $patron->checkouts->count, 1, 'Checkout should have been done successfully'); + is( $patron->checkouts->count, 1, 'Checkout should have been done successfully' ); # Checkin my $ci_transaction = C4::SIP::ILS::Transaction::Checkin->new(); - is( $ci_transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $ci_transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $ci_transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $ci_transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); - my $checkin = $ci_transaction->do_checkin($library->branchcode, C4::SIP::Sip::timestamp); - is( $patron->checkouts->count, 0, 'Checkin should have been done successfully'); + my $checkin = $ci_transaction->do_checkin( $library->branchcode, C4::SIP::Sip::timestamp ); + is( $patron->checkouts->count, 0, 'Checkin should have been done successfully' ); # Test checkin without return date $co_transaction->do_checkout; - is( $patron->checkouts->count, 1, 'Checkout should have been done successfully'); - $ci_transaction->do_checkin($library->branchcode, undef); - is( $patron->checkouts->count, 0, 'Checkin should have been done successfully'); + is( $patron->checkouts->count, 1, 'Checkout should have been done successfully' ); + $ci_transaction->do_checkin( $library->branchcode, undef ); + is( $patron->checkouts->count, 0, 'Checkin should have been done successfully' ); - my $result = $ci_transaction->do_checkin($library2->branchcode, undef); - is($ci_transaction->alert_type,'04',"Checkin of item no issued at another branch succeeds"); + my $result = $ci_transaction->do_checkin( $library2->branchcode, undef ); + is( $ci_transaction->alert_type, '04', "Checkin of item no issued at another branch succeeds" ); is_deeply( $result, { @@ -399,22 +416,22 @@ subtest do_checkin => sub { }, "Messages show not issued and transferred" ); - is( $ci_transaction->item->destination_loc,$library->branchcode,"Item destination correctly set"); + is( $ci_transaction->item->destination_loc, $library->branchcode, "Item destination correctly set" ); subtest 'Checkin an in transit item' => sub { plan tests => 5; - my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); - my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); + my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); + my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); - my $patron = $builder->build_object({ class => 'Koha::Patrons', value => {branchcode => $library_1->branchcode, }}); + my $patron = + $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library_1->branchcode, } } ); my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); - my $item = $builder->build_sample_item({ library => $library_1->branchcode }); + my $item = $builder->build_sample_item( { library => $library_1->branchcode } ); my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - t::lib::Mocks::mock_userenv( - { branchcode => $library_1->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library_1->branchcode, flags => 1 } ); my $reserve = AddReserve( { @@ -424,28 +441,32 @@ subtest do_checkin => sub { } ); - ModReserveAffect( $item->itemnumber, $patron->borrowernumber ); # Mark waiting + ModReserveAffect( $item->itemnumber, $patron->borrowernumber ); # Mark waiting my $ci_transaction = C4::SIP::ILS::Transaction::Checkin->new(); - is( $ci_transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $ci_transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $ci_transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $ci_transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); - my $checkin = $ci_transaction->do_checkin($library_2->branchcode, C4::SIP::Sip::timestamp); + my $checkin = $ci_transaction->do_checkin( $library_2->branchcode, C4::SIP::Sip::timestamp ); my $hold = Koha::Holds->find($reserve); - is( $hold->found, 'T', ); - is( $hold->itemnumber, $item->itemnumber, ); - is( Koha::Checkouts->search({itemnumber => $item->itemnumber})->count, 0, ); + is( $hold->found, 'T', ); + is( $hold->itemnumber, $item->itemnumber, ); + is( Koha::Checkouts->search( { itemnumber => $item->itemnumber } )->count, 0, ); }; subtest 'Checkin with fines' => sub { plan tests => 2; - my $mockILS = Test::MockObject->new; - my $server = { ils => $mockILS }; - my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $mockILS = Test::MockObject->new; + my $server = { ils => $mockILS }; + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $institution = { id => $library->id, implementation => "ILS", @@ -457,7 +478,7 @@ subtest do_checkin => sub { retries => 5, } }; - my $ils = C4::SIP::ILS->new($institution); + my $ils = C4::SIP::ILS->new($institution); my $item = $builder->build_sample_item( { library => $library->branchcode, @@ -473,19 +494,22 @@ subtest do_checkin => sub { } } ); - my $circ = $ils->checkout($patron->cardnumber, $item->barcode, undef, undef, $server->{account}); + my $circ = $ils->checkout( $patron->cardnumber, $item->barcode, undef, undef, $server->{account} ); my $fee1 = $builder->build( { source => 'Accountline', value => { - borrowernumber => $patron->borrowernumber, + borrowernumber => $patron->borrowernumber, amountoutstanding => 12, debit_type_code => 'OVERDUE', itemnumber => $item->itemnumber } } ); - $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode, undef, undef, $server->{account} ); + $circ = $ils->checkin( + $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode, undef, undef, + $server->{account} + ); is( $circ->{screen_msg}, '', "The fine is not displayed on checkin when show_outstanding_amount is disabled" ); # show_outstanding_amount enabled @@ -497,13 +521,13 @@ subtest do_checkin => sub { } } ); - $circ = $ils->checkout($patron->cardnumber, $item->barcode, undef, undef, $server->{account}); + $circ = $ils->checkout( $patron->cardnumber, $item->barcode, undef, undef, $server->{account} ); $fee1 = $builder->build( { source => 'Accountline', value => { - borrowernumber => $patron->borrowernumber, + borrowernumber => $patron->borrowernumber, amountoutstanding => 12, debit_type_code => 'OVERDUE', itemnumber => $item->itemnumber @@ -512,10 +536,16 @@ subtest do_checkin => sub { ); $server->{account}->{show_outstanding_amount} = 1; - $circ = $ils->checkout($patron->cardnumber, $item->barcode, undef, undef, $server->{account}); + $circ = $ils->checkout( $patron->cardnumber, $item->barcode, undef, undef, $server->{account} ); - $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode, undef, undef, $server->{account} ); - is( $circ->{screen_msg}, 'You owe $12.00 for this item.', "The fine is displayed on checkin when show_outstanding_amount is enabled" ); + $circ = $ils->checkin( + $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode, undef, undef, + $server->{account} + ); + is( + $circ->{screen_msg}, 'You owe $12.00 for this item.', + "The fine is displayed on checkin when show_outstanding_amount is enabled" + ); }; }; @@ -523,9 +553,9 @@ subtest do_checkin => sub { subtest do_checkout_with_sysprefs_override => sub { plan tests => 8; - my $mockILS = Test::MockObject->new; - my $server = { ils => $mockILS }; - my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $mockILS = Test::MockObject->new; + my $server = { ils => $mockILS }; + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $institution = { id => $library->id, implementation => "ILS", @@ -537,7 +567,7 @@ subtest do_checkout_with_sysprefs_override => sub { retries => 5, } }; - my $ils = C4::SIP::ILS->new($institution); + my $ils = C4::SIP::ILS->new($institution); my $item = $builder->build_sample_item( { library => $library->branchcode, @@ -557,7 +587,7 @@ subtest do_checkout_with_sysprefs_override => sub { { source => 'Accountline', value => { - borrowernumber => $patron_under_noissuescharge->borrowernumber, + borrowernumber => $patron_under_noissuescharge->borrowernumber, amountoutstanding => 4, debit_type_code => 'OVERDUE', } @@ -578,63 +608,89 @@ subtest do_checkout_with_sysprefs_override => sub { { source => 'Accountline', value => { - borrowernumber => $patron_over_noissuescharge->borrowernumber, + borrowernumber => $patron_over_noissuescharge->borrowernumber, amountoutstanding => 6, debit_type_code => 'OVERDUE', } } ); - $server->{account}->{override_fine_on_checkout} = 0; t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '0' ); - t::lib::Mocks::mock_preference( 'AllowFineOverride', '0' ); - my $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_under_noissuescharge->checkouts->count, 1, 'Checkout is allowed when the amount is under noissuecharge, AllFinesNeedOverride and AllowFineOverride disabled'); + t::lib::Mocks::mock_preference( 'AllowFineOverride', '0' ); + my $circ = + $ils->checkout( $patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_under_noissuescharge->checkouts->count, 1, + 'Checkout is allowed when the amount is under noissuecharge, AllFinesNeedOverride and AllowFineOverride disabled' + ); $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); - $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride and AllowFineOverride disabled'); + $circ = $ils->checkout( $patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_over_noissuescharge->checkouts->count, 0, + 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride and AllowFineOverride disabled' + ); t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '0' ); - t::lib::Mocks::mock_preference( 'AllowFineOverride', '1' ); + t::lib::Mocks::mock_preference( 'AllowFineOverride', '1' ); - $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_under_noissuescharge->checkouts->count, 1, 'Checkout is allowed when the amount is under noissuecharge, AllFinesNeedOverride disabled and AllowFineOverride enabled'); + $circ = + $ils->checkout( $patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_under_noissuescharge->checkouts->count, 1, + 'Checkout is allowed when the amount is under noissuecharge, AllFinesNeedOverride disabled and AllowFineOverride enabled' + ); $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); - $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride disabled and AllowFineOverride enabled'); + $circ = $ils->checkout( $patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_over_noissuescharge->checkouts->count, 0, + 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride disabled and AllowFineOverride enabled' + ); t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '1' ); - t::lib::Mocks::mock_preference( 'AllowFineOverride', '0' ); + t::lib::Mocks::mock_preference( 'AllowFineOverride', '0' ); - $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_under_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is under noissuecharge, AllFinesNeedOverride enabled and AllowFineOverride disabled'); + $circ = + $ils->checkout( $patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_under_noissuescharge->checkouts->count, 0, + 'Checkout is blocked when the amount is under noissuecharge, AllFinesNeedOverride enabled and AllowFineOverride disabled' + ); - $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride enabled and AllowFineOverride disabled'); + $circ = $ils->checkout( $patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_over_noissuescharge->checkouts->count, 0, + 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride enabled and AllowFineOverride disabled' + ); t::lib::Mocks::mock_preference( 'AllFinesNeedOverride', '1' ); - t::lib::Mocks::mock_preference( 'AllowFineOverride', '1' ); + t::lib::Mocks::mock_preference( 'AllowFineOverride', '1' ); - $circ = $ils->checkout($patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_under_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is under noissuecharge, AllFinesNeedOverride and AllowFineOverride enabled'); + $circ = + $ils->checkout( $patron_under_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_under_noissuescharge->checkouts->count, 0, + 'Checkout is blocked when the amount is under noissuecharge, AllFinesNeedOverride and AllowFineOverride enabled' + ); - $circ = $ils->checkout($patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account}); - is( $patron_over_noissuescharge->checkouts->count, 0, 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride and AllowFineOverride enabled'); + $circ = $ils->checkout( $patron_over_noissuescharge->cardnumber, $item->barcode, undef, undef, $server->{account} ); + is( + $patron_over_noissuescharge->checkouts->count, 0, + 'Checkout is blocked when the amount is over noissuecharge, AllFinesNeedOverride and AllowFineOverride enabled' + ); }; - subtest do_checkout_with_patron_blocked => sub { plan tests => 5; - my $mockILS = Test::MockObject->new; - my $server = { ils => $mockILS }; - my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $mockILS = Test::MockObject->new; + my $server = { ils => $mockILS }; + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $institution = { id => $library->id, implementation => "ILS", @@ -646,7 +702,7 @@ subtest do_checkout_with_patron_blocked => sub { retries => 5, } }; - my $ils = C4::SIP::ILS->new($institution); + my $ils = C4::SIP::ILS->new($institution); my $item = $builder->build_sample_item( { library => $library->branchcode, @@ -662,7 +718,7 @@ subtest do_checkout_with_patron_blocked => sub { } } ); - my $circ = $ils->checkout($expired_patron->cardnumber, $item->barcode); + my $circ = $ils->checkout( $expired_patron->cardnumber, $item->barcode ); is( $circ->{screen_msg}, 'Patron expired on 01/03/2020', "Got correct expired screen message" ); my $fines_patron = $builder->build_object( @@ -677,32 +733,32 @@ subtest do_checkout_with_patron_blocked => sub { { source => 'Accountline', value => { - borrowernumber => $fines_patron->borrowernumber, + borrowernumber => $fines_patron->borrowernumber, amountoutstanding => 10, debit_type_code => 'OVERDUE', } } ); - my $fines_sip_patron = C4::SIP::ILS::Patron->new( $fines_patron->cardnumber ); + my $fines_sip_patron = C4::SIP::ILS::Patron->new( $fines_patron->cardnumber ); - $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); + $circ = $ils->checkout( $fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account} ); is( $circ->{screen_msg}, 'Patron has fines', "Got correct fines screen message" ); $server->{account}->{show_outstanding_amount} = 1; - $circ = $ils->checkout($fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account}); + $circ = $ils->checkout( $fines_patron->cardnumber, $item->barcode, undef, undef, $server->{account} ); is( $circ->{screen_msg}, 'Patron has fines - You owe $10.00.', "Got correct fines with amount screen message" ); my $debarred_patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->branchcode, - debarred => '9999/01/01', + debarred => '9999/01/01', } } ); - my $debarred_sip_patron = C4::SIP::ILS::Patron->new( $debarred_patron->cardnumber ); - $circ = $ils->checkout($debarred_patron->cardnumber, $item->barcode); + my $debarred_sip_patron = C4::SIP::ILS::Patron->new( $debarred_patron->cardnumber ); + $circ = $ils->checkout( $debarred_patron->cardnumber, $item->barcode ); is( $circ->{screen_msg}, 'Patron debarred', "Got correct debarred screen message" ); my $overdue_patron = $builder->build_object( @@ -714,14 +770,18 @@ subtest do_checkout_with_patron_blocked => sub { } ); - my $odue = $builder->build({ source => 'Issue', value => { - borrowernumber => $overdue_patron->borrowernumber, - date_due => '2017-01-01', + my $odue = $builder->build( + { + source => 'Issue', + value => { + borrowernumber => $overdue_patron->borrowernumber, + date_due => '2017-01-01', + } } - }); + ); t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); - my $overdue_sip_patron = C4::SIP::ILS::Patron->new( $overdue_patron->cardnumber ); - $circ = $ils->checkout($overdue_patron->cardnumber, $item->barcode); + my $overdue_sip_patron = C4::SIP::ILS::Patron->new( $overdue_patron->cardnumber ); + $circ = $ils->checkout( $overdue_patron->cardnumber, $item->barcode ); is( $circ->{screen_msg}, 'Patron blocked', "Got correct blocked screen message" ); }; @@ -730,18 +790,17 @@ subtest do_checkout_with_noblock => sub { plan tests => 3; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $patron = $builder->build_object( + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->branchcode, - debarred => '9999/01/01', + debarred => '9999/01/01', }, } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { @@ -749,25 +808,28 @@ subtest do_checkout_with_noblock => sub { } ); - - my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); - my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new(); - is( $co_transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $co_transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $co_transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $co_transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); - $co_transaction->do_checkout(undef, '19990102 030405'); + $co_transaction->do_checkout( undef, '19990102 030405' ); - is( $patron->checkouts->count, 1, 'No Block checkout was performed for debarred patron'); + is( $patron->checkouts->count, 1, 'No Block checkout was performed for debarred patron' ); }; subtest do_checkout_with_holds => sub { plan tests => 7; my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $patron = $builder->build_object( + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { @@ -784,8 +846,7 @@ subtest do_checkout_with_holds => sub { } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { @@ -795,43 +856,47 @@ subtest do_checkout_with_holds => sub { my $reserve = AddReserve( { - branchcode => $library->branchcode, - borrowernumber => $patron2->borrowernumber, - biblionumber => $item->biblionumber, + branchcode => $library->branchcode, + borrowernumber => $patron2->borrowernumber, + biblionumber => $item->biblionumber, } ); - my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); - my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new(); - is( $co_transaction->patron($sip_patron), - $sip_patron, "Patron assigned to transaction" ); - is( $co_transaction->item($sip_item), - $sip_item, "Item assigned to transaction" ); + is( + $co_transaction->patron($sip_patron), + $sip_patron, "Patron assigned to transaction" + ); + is( + $co_transaction->item($sip_item), + $sip_item, "Item assigned to transaction" + ); # Test attached holds - ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) + ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) my $hold = Koha::Holds->find($reserve); $co_transaction->do_checkout(); - is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)'); + is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)' ); $hold->set_transfer; $co_transaction->do_checkout(); - is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)'); + is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)' ); $hold->set_processing; $co_transaction->do_checkout(); - is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)'); + is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)' ); # Test non-attached holds - C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber }); - t::lib::Mocks::mock_preference('AllowItemsOnHoldCheckoutSIP', '0'); + C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); + t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '0' ); $co_transaction->do_checkout(); - is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP'); + is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP' ); - t::lib::Mocks::mock_preference('AllowItemsOnHoldCheckoutSIP', '1'); + t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '1' ); $co_transaction->do_checkout(); - is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP'); + is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP' ); }; subtest checkin_lost => sub { @@ -839,12 +904,11 @@ subtest checkin_lost => sub { my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { - library => $library->branchcode, + library => $library->branchcode, } ); @@ -861,13 +925,13 @@ subtest checkin_lost => sub { retries => 5, } }; - my $ils = C4::SIP::ILS->new( $instituation ); + my $ils = C4::SIP::ILS->new($instituation); - t::lib::Mocks::mock_preference('BlockReturnOfLostItems', '1'); + t::lib::Mocks::mock_preference( 'BlockReturnOfLostItems', '1' ); my $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); is( $circ->{screen_msg}, 'Item lost, return not allowed', "Got correct screen message" ); - t::lib::Mocks::mock_preference('BlockReturnOfLostItems', '0'); + t::lib::Mocks::mock_preference( 'BlockReturnOfLostItems', '0' ); $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); is( $circ->{screen_msg}, 'Item not checked out', "Got 'Item not checked out' screen message" ); }; @@ -877,12 +941,11 @@ subtest checkin_withdrawn => sub { my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { - library => $library->branchcode, + library => $library->branchcode, } ); @@ -899,13 +962,13 @@ subtest checkin_withdrawn => sub { retries => 5, } }; - my $ils = C4::SIP::ILS->new( $instituation ); + my $ils = C4::SIP::ILS->new($instituation); - t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', '1'); + t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', '1' ); my $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); is( $circ->{screen_msg}, 'Item withdrawn, return not allowed', "Got correct screen message" ); - t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', '0'); + t::lib::Mocks::mock_preference( 'BlockReturnOfWithdrawnItems', '0' ); $circ = $ils->checkin( $item->barcode, C4::SIP::Sip::timestamp, undef, $library->branchcode ); is( $circ->{screen_msg}, 'Item not checked out', "Got 'Item not checked out' screen message" ); }; @@ -929,12 +992,12 @@ $branch2:effective_itemtype:eq:CD:4\r $branch2:itemcallnumber:>:600:5\r $branch2:effective_itemtype:eq:BOOK:ccode:eq:TEEN:6\r RULES - t::lib::Mocks::mock_preference('SIP2SortBinMapping', $rules); + t::lib::Mocks::mock_preference( 'SIP2SortBinMapping', $rules ); my $item_cd = $builder->build_sample_item( { - library => $library->branchcode, - itype => 'CD' + library => $library->branchcode, + itype => 'CD' } ); @@ -957,22 +1020,22 @@ RULES my $bin; # Set holdingbranch as though item returned to library other than homebranch (As AddReturn would) - $item_cd->holdingbranch($library2->branchcode)->store(); + $item_cd->holdingbranch( $library2->branchcode )->store(); $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_cd, $library2->branchcode ); - is($bin, 'X', "Item parameter on RHS of comparison works (ne comparator)"); + is( $bin, 'X', "Item parameter on RHS of comparison works (ne comparator)" ); # Reset holdingbranch as though item returned to home library - $item_cd->holdingbranch($library->branchcode)->store(); + $item_cd->holdingbranch( $library->branchcode )->store(); $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_cd, $library->branchcode ); - is($bin, '0', "Fixed value on RHS of comparison works (eq comparator)"); + is( $bin, '0', "Fixed value on RHS of comparison works (eq comparator)" ); $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_book, $library->branchcode ); - is($bin, '1', "Rules applied in order (< comparator)"); + is( $bin, '1', "Rules applied in order (< comparator)" ); $item_book->itemcallnumber('350.20')->store(); $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_book, $library->branchcode ); - is($bin, '2', "Rules applied in order (< comparator)"); + is( $bin, '2', "Rules applied in order (< comparator)" ); $bin = C4::SIP::ILS::Transaction::Checkin::_get_sort_bin( $item_book2, $library2->branchcode ); - is($bin, '6', "Rules with multiple field matches"); + is( $bin, '6', "Rules with multiple field matches" ); }; subtest item_circulation_status => sub { @@ -990,8 +1053,7 @@ subtest item_circulation_status => sub { } ); - t::lib::Mocks::mock_userenv( - { branchcode => $library->branchcode, flags => 1 } ); + t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); my $item = $builder->build_sample_item( { @@ -1000,58 +1062,62 @@ subtest item_circulation_status => sub { ); my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - my $status = $sip_item->sip_circulation_status; - is( $status, '03', "Item circulation status is available"); + my $status = $sip_item->sip_circulation_status; + is( $status, '03', "Item circulation status is available" ); - my $transfer = Koha::Item::Transfer->new({ - itemnumber => $item->id, - datesent => '2020-01-01', - frombranch => $library->branchcode, - tobranch => $library2->branchcode, - })->store(); + my $transfer = Koha::Item::Transfer->new( + { + itemnumber => $item->id, + datesent => '2020-01-01', + frombranch => $library->branchcode, + tobranch => $library2->branchcode, + } + )->store(); $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - $status = $sip_item->sip_circulation_status; + $status = $sip_item->sip_circulation_status; is( $status, '10', "Item circulation status is in transit" ); $transfer->delete; - my $claim = Koha::Checkouts::ReturnClaim->new({ - itemnumber => $item->id, - borrowernumber => $patron->id, - created_by => $patron->id, - })->store(); + my $claim = Koha::Checkouts::ReturnClaim->new( + { + itemnumber => $item->id, + borrowernumber => $patron->id, + created_by => $patron->id, + } + )->store(); $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - $status = $sip_item->sip_circulation_status; + $status = $sip_item->sip_circulation_status; is( $status, '11', "Item circulation status is claimed returned" ); $claim->delete; $item->itemlost(1)->store(); $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - $status = $sip_item->sip_circulation_status; + $status = $sip_item->sip_circulation_status; is( $status, '12', "Item circulation status is lost" ); $item->itemlost(0)->store(); my $location = $item->location; $item->location("CART")->store(); $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - $status = $sip_item->sip_circulation_status; + $status = $sip_item->sip_circulation_status; is( $status, '09', "Item circulation status is waiting to be re-shelved" ); $item->location($location)->store(); my $nfl = $item->notforloan; $item->notforloan(-1)->store(); $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - $status = $sip_item->sip_circulation_status; + $status = $sip_item->sip_circulation_status; is( $status, '02', "Item circulation status is on order" ); $item->notforloan($nfl)->store(); my $damaged = $item->damaged; $item->damaged(1)->store(); $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); - $status = $sip_item->sip_circulation_status; + $status = $sip_item->sip_circulation_status; is( $status, '01', "Item circulation status is damaged" ); $item->damaged(0)->store(); }; -- 2.41.0