From bc7f1c820e0627ff3c20735635118151c7672ea1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 4 Nov 2022 20:17:08 -0300 Subject: [PATCH] Bug 31907: (QA follow-up) Simplify tests This patch simplipfies the tests, and highlighs the fact the introduced method should add filters to the current resultset. It also aligns the tests with the currently adopted style. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Holds.t | 39 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index 5e055307ff..5a86d76261 100755 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use Test::Warn; use C4::Circulation qw( AddIssue ); @@ -745,52 +745,37 @@ subtest 'filter_by_has_cancellation_requests() and filter_out_has_cancellation_r $schema->storage->txn_rollback; }; -subtest 'get holds in processing' => sub { +subtest 'processing() tests' => sub { - plan tests => 1; + plan tests => 3; $schema->storage->txn_begin; - my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); - - my $item = $builder->build_sample_item; - my $hold_1 = $builder->build_object( { class => 'Koha::Holds', - value => { - found => 'P', - itemnumber => $item->id, - biblionumber => $item->biblionumber, - borrowernumber => $patron->id - } + value => { found => 'P' } } ); my $hold_2 = $builder->build_object( { class => 'Koha::Holds', - value => { - found => undef, - itemnumber => $item->id, - biblionumber => $item->biblionumber, - borrowernumber => $patron->id - } + value => { found => undef } } ); my $hold_3 = $builder->build_object( { class => 'Koha::Holds', - value => { - found => undef, - itemnumber => $item->id, - biblionumber => $item->biblionumber, - borrowernumber => $patron->id - } + value => { found => 'T' } } ); - my $processing_holds = $item->holds->processing; - is( $processing_holds->count, 1 ); + my $holds = Koha::Holds->search({ reserve_id => [ $hold_1->id, $hold_2->id, $hold_3->id ] }); + is( $holds->count, 3, 'Resultset contains 3 holds' ); + + my $processing = $holds->processing; + is( $processing->count, 1 ); + is( $processing->next->id, $hold_1->id, "First hold is the only one in 'processing'" ); $schema->storage->txn_rollback; };