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:
parent
33021aa214
commit
f7cc43fd22
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue