Bug 37334: filter_by_in_bundle tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2025-01-13 21:32:42 +00:00 committed by Katrin Fischer
parent fd6a61a280
commit fcb2c83ea0
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 33 additions and 1 deletions

View File

@ -20,7 +20,7 @@
use Modern::Perl;
use Test::NoWarnings;
use Test::More tests => 23;
use Test::More tests => 24;
use Test::MockModule;
use Test::Exception;
@ -2547,3 +2547,35 @@ subtest 'filter_by_has_holds' => sub {
$schema->storage->txn_rollback;
};
subtest 'filter_by_in_bundle' => sub {
plan tests => 3;
$schema->storage->txn_begin;
my $library = $builder->build( { source => 'Branch' } );
my $biblio = $builder->build_sample_biblio();
my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
my $item_3 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
is( $biblio->items->filter_by_in_bundle->count, 0, "0 items in a bundle for this record" );
my $in_bundle = $item_1->in_bundle;
my $host_item = $builder->build_sample_item();
$schema->resultset('ItemBundle')->create( { host => $host_item->itemnumber, item => $item_1->itemnumber } );
$in_bundle = $item_1->in_bundle;
is( $biblio->items->filter_by_in_bundle->count, 1, "1 item in a bundle for this record" );
$schema->resultset('ItemBundle')->create( { host => $host_item->itemnumber, item => $item_2->itemnumber } );
$in_bundle = $item_2->in_bundle;
is( $biblio->items->filter_by_in_bundle->count, 2, "2 items in a bundle for this record" );
$schema->storage->txn_rollback;
};