Bug 18501: (follow-up) Test undefined userenv behaviour
This patch adds a test to ensure that the 'Koha::Item->store' method will function when the userenv is not set Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
00ec4ed478
commit
3a8866cae6
1 changed files with 50 additions and 1 deletions
|
@ -136,7 +136,7 @@ subtest 'store' => sub {
|
|||
};
|
||||
|
||||
subtest '_lost_found_trigger' => sub {
|
||||
plan tests => 6;
|
||||
plan tests => 7;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 );
|
||||
t::lib::Mocks::mock_preference( 'WhenLostForgiveFine', 0 );
|
||||
|
@ -758,6 +758,53 @@ subtest 'store' => sub {
|
|||
is( $item->{_refunded}, undef, 'No refund triggered' );
|
||||
|
||||
};
|
||||
|
||||
subtest 'Continue when userenv is not set' => sub {
|
||||
plan tests => 1;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $barcode = 'KD123456795';
|
||||
my $replacement_amount = 100;
|
||||
my $processfee_amount = 20;
|
||||
|
||||
my $item_type = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::ItemTypes',
|
||||
value => {
|
||||
notforloan => undef,
|
||||
rentalcharge => 0,
|
||||
defaultreplacecost => undef,
|
||||
processfee => 0,
|
||||
rentalcharge_daily => 0,
|
||||
}
|
||||
}
|
||||
);
|
||||
my $item = $builder->build_sample_item(
|
||||
{
|
||||
biblionumber => $biblio->biblionumber,
|
||||
homebranch => $library->branchcode,
|
||||
holdingbranch => $library->branchcode,
|
||||
barcode => $barcode,
|
||||
replacementprice => $replacement_amount,
|
||||
itype => $item_type->itemtype
|
||||
}
|
||||
);
|
||||
|
||||
my $issue =
|
||||
C4::Circulation::AddIssue( $patron->unblessed, $barcode );
|
||||
|
||||
# Simulate item marked as lost
|
||||
$item->itemlost(1)->store;
|
||||
C4::Circulation::LostItem( $item->itemnumber, 1 );
|
||||
|
||||
# Unset the userenv
|
||||
C4::Context->_new_userenv(undef);
|
||||
|
||||
# Simluate item marked as found
|
||||
$item->itemlost(0)->store;
|
||||
is( $item->{_refunded}, 1, 'No refund triggered' );
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -815,6 +862,8 @@ subtest 'biblioitem' => sub {
|
|||
is( $biblioitem->biblionumber, $retrieved_item_1->biblionumber, 'Koha::Item->biblioitem should return the correct biblioitem' );
|
||||
};
|
||||
|
||||
# Restore userenv
|
||||
t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
|
||||
subtest 'checkout' => sub {
|
||||
plan tests => 5;
|
||||
my $item = Koha::Items->find( $new_item_1->itemnumber );
|
||||
|
|
Loading…
Reference in a new issue