From 08fa7014c065e5a5bf3d2e9e6fd50c52f45a068a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 9 Nov 2018 10:54:12 -0300 Subject: [PATCH] Bug 21413: (QA follow-up) Fix tests No assumption on the order in which restults are returned should be made (we don't control existing data on the tests). So it should only check existence of expected records in the results, and absense. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Items/GetItemsForInventory.t | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t index 39e0ae6696..fddea80ad0 100755 --- a/t/db_dependent/Items/GetItemsForInventory.t +++ b/t/db_dependent/Items/GetItemsForInventory.t @@ -22,6 +22,8 @@ use Modern::Perl; use Test::More tests => 7; use t::lib::TestBuilder; +use List::MoreUtils qw( any none ); + use C4::Biblio qw(AddBiblio); use C4::Reserves; use Koha::AuthorisedValues; @@ -59,7 +61,7 @@ subtest 'Old version is unchanged' => sub { subtest 'Skip items with waiting holds' => sub { - plan tests => 5; + plan tests => 6; $schema->storage->txn_begin; @@ -69,8 +71,8 @@ subtest 'Skip items with waiting holds' => sub { my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->id } } ); - my $title_1 = 'Title 1'; - my $title_2 = 'Title 2'; + my $title_1 = 'Title 1, '; + my $title_2 = 'Title 2, bizzarre one so doesn\'t already exist'; my $biblio_1 = create_helper_biblio( $itemtype->itemtype, $title_1 ); my $biblio_2 = create_helper_biblio( $itemtype->itemtype, $title_2 ); @@ -117,8 +119,10 @@ subtest 'Skip items with waiting holds' => sub { my ( $new_items, $new_items_count ) = GetItemsForInventory( { ignore_waiting_holds => 1 } ); is( $new_items_count, $first_items_count + 1, 'Item on hold skipped, count makes sense' ); - is( $new_items->[ scalar @{$new_items} - 1 ]->{title}, - $title_2, 'Item on hold skipped, last item is the correct one' ); + ok( (any { $_->{title} eq $title_2 } @{$new_items}), + 'Item on hold skipped, the other one we added is present' ); + ok( (none { $_->{title} eq $title_1 } @{$new_items}), + 'Item on hold skipped, no one matches' ); $schema->storage->txn_rollback; }; -- 2.19.1