From 3c7258fc09d53dcf63c06413a36f99abeb2277ed Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 29 Aug 2023 09:34:04 +0000 Subject: [PATCH] Bug 34639: (DO NOT PUSH) Add tests To reproduce: 1. Add an item to library A 2. Go to Circulation -> Transfer 3. Transfer the item from library A to another library B 4. Set your currently logged in library to library B 5. Check-in the item 6. Observe message "Item received from A" 7. View the bibliographic record of the item (catalogue/detail.pl) 8. Observe item in "In transit from A to B since xx/xx/xxxx Available" To test: 1. prove t/db_dependent/Koha/Item/Transfer.t --- t/db_dependent/Koha/Item/Transfer.t | 40 ++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item/Transfer.t b/t/db_dependent/Koha/Item/Transfer.t index 2ac3462351..2b4b7e78ca 100755 --- a/t/db_dependent/Koha/Item/Transfer.t +++ b/t/db_dependent/Koha/Item/Transfer.t @@ -24,12 +24,50 @@ use Koha::DateUtils qw( dt_from_string ); use t::lib::TestBuilder; -use Test::More tests => 7; +use Test::More tests => 8; use Test::Exception; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; +subtest 'detail.tt not in transit after transfer has arrived' => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + my $item = $builder->build_sample_item(); + my $transfer = $builder->build_object( + { + class => 'Koha::Item::Transfers', + value => { + itemnumber => $item->itemnumber, + datesent => dt_from_string, + datearrived => dt_from_string, + } + } + ); + + my $transfer_item = $transfer->item; + my $biblio = Koha::Biblios->find($transfer_item->biblionumber); + + my $items_params = { host_items => 1 }; + my $params = {}; + + # FROM catalogue/detail.pl + my $items = $biblio->items($items_params)->search_ordered( $params, { prefetch => ['issue','current_branchtransfers'] } ); + # but minimum testable case would be + #my $items = Koha::Items->search( { 'me.itemnumber' => $transfer_item->itemnumber }, { prefetch => ['current_branchtransfers'] } ); + + my $detail_tt_item = $items->next; + + # following two tests should produce the same result + is($transfer_item->itemnumber, $detail_tt_item->itemnumber, 'following two items are the same'); + is($transfer_item->get_transfer, undef, 'Koha::Item->get_transfer returns undef'); + is($detail_tt_item->get_transfer, undef, 'detail.tt->get_transfer returns undef'); + + $schema->storage->txn_rollback; +}; + subtest 'item relation tests' => sub { plan tests => 2; -- 2.34.1