From 1d973ca728a740f8433ba5a577888cd19702c52d Mon Sep 17 00:00:00 2001 From: Michal Urban Date: Wed, 15 Jun 2022 04:51:25 -0400 Subject: [PATCH] Added test to ensure that Koha::Holds->get_items_that_can_fill returns items with either datecancelled or datearrived (inclusive). I made an error with my understanding of my boolean logic. Also cleaned up the variables in the test by removing unblessed and using the variable base forms. https://bugs.koha-community.org/show_bug.cgi?id=30447 --- t/db_dependent/Holds.t | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 6d58be2bbe..5b2140796a 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -1705,8 +1705,8 @@ subtest 'ModReserve can only update expirationdate for found holds' => sub { }; -subtest 'Koha::Holds->get_items_that_can_fill returns items with datecancelled and datearrived' => sub { - plan tests => 4; +subtest 'Koha::Holds->get_items_that_can_fill returns items with datecancelled or (inclusive) datearrived' => sub { + plan tests => 5; # biblio item with date arrived and date cancelled my $biblio1 = $builder->build_sample_biblio(); my $item1 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber }); @@ -1785,17 +1785,9 @@ subtest 'Koha::Holds->get_items_that_can_fill returns items with datecancelled a my $items_that_can_fill3 = $holds3->get_items_that_can_fill; my $items_that_can_fill4 = $holds4->get_items_that_can_fill; - # get the item number that will be compared to with the items that are called which get_items_that_can_fill returns - my %item_unblessed1 = $item1->unblessed; - # used for first test case - - my %items_that_can_fill_unblessed1 = $items_that_can_fill1->unblessed; - my %items_that_can_fill_unblessed2 = $items_that_can_fill2->unblessed; - my %items_that_can_fill_unblessed3 = $items_that_can_fill3->unblessed; - my %items_that_can_fill_unblessed4 = $items_that_can_fill4->unblessed; - - is($items_that_can_fill_unblessed1{"itemnumber"}, $item_unblessed1{"itemnumber"}, "Koha::Holds->get_items_that_can_fill returns item with defined datearrived and datecancelled"); - is($items_that_can_fill_unblessed2{"itemnumber"}, undef, "Koha::Holds->get_items_that_can_fill doesn't return item with defined datearrived and undefined datecancelled"); - is($items_that_can_fill_unblessed3{"itemnumber"}, undef, "Koha::Holds->get_items_that_can_fill doesn't return item with undefined datearrived and defined datecancelled"); - is($items_that_can_fill_unblessed3{"itemnumber"}, undef, "Koha::Holds->get_items_that_can_fill doesn't return item with undefined datearrived and undefined datecancelled"); + is($items_that_can_fill1->next->id, $item1->id, "Koha::Holds->get_items_that_can_fill returns item with defined datearrived and datecancelled"); + is($items_that_can_fill1->count, 1, "Koha::Holds->get_items_that_can_fill returns 1 item with correct parameters"); + is($items_that_can_fill2->next->id, $item2->id, "Koha::Holds->get_items_that_can_fill returns item with defined datearrived and undefined datecancelled"); + is($items_that_can_fill3->next->id, $item3->id, "Koha::Holds->get_items_that_can_fill returns item with undefined datearrived and defined datecancelled"); + is($items_that_can_fill4->next, undef, "Koha::Holds->get_items_that_can_fill doesn't return item with undefined datearrived and undefined datecancelled"); } -- 2.25.1