Bug 35906: (QA follow-up) Unit tests for effective_bookable

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-10-18 11:40:45 +01:00 committed by Katrin Fischer
parent 33021aa214
commit f7cc43fd22
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 57 additions and 1 deletions

View File

@ -20,7 +20,7 @@
use Modern::Perl;
use utf8;
use Test::More tests => 37;
use Test::More tests => 38;
use Test::Exception;
use Test::MockModule;
@ -3254,3 +3254,59 @@ subtest 'effective_not_for_loan_status() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'effective_bookable() tests' => sub {
plan tests => 5;
$schema->storage->txn_begin;
my $biblio = $builder->build_sample_biblio;
my $biblio_itype = Koha::ItemTypes->find( $biblio->itemtype );
$biblio_itype->bookable(0)->store();
$biblio_itype->discard_changes;
my $item_itype = $builder->build_object( { class => 'Koha::ItemTypes' } );
$item_itype->bookable(1)->store();
$item_itype->discard_changes;
my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itype => $item_itype->itemtype } );
$item->bookable(undef)->store();
$item->discard_changes;
isnt( $biblio->itemtype, $item_itype->itemtype, "Biblio level itemtype and item level itemtype does not match" );
t::lib::Mocks::mock_preference( 'item-level_itypes', 0 );
note("item-level_itypes: 0");
is(
$item->effective_bookable, $biblio_itype->bookable,
'->effective_bookable returns biblio level itemtype bookable value when item bookable is undefined'
);
$item->bookable(1)->store();
$item->discard_changes;
isnt(
$item->effective_bookable, $biblio_itype->bookable,
'->effective_bookable returns item specific bookable value when item bookable is defined'
);
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
note("item-level_itypes: 1");
$item->bookable(undef)->store();
$item->discard_changes;
is(
$item->effective_bookable, $item_itype->bookable,
'->effective_bookable returns item level itemtype bookable value when item bookable is undefined'
);
$item->bookable(0)->store();
$item->discard_changes;
isnt(
$item->effective_bookable, $item_itype->bookable,
'->effective_bookable returns item specific bookable value when item bookable is defined'
);
$schema->storage->txn_rollback;
};