Bug 35612: (QA follow-up) Add test for undefined LostChargesControl preference
Adds test coverage for the case where LostChargesControl system preference is not set (returns undef). This ensures the code handles this gracefully and defaults to ItemHomeLibrary behavior. The test verifies that: - No warnings are generated when the preference is undefined - The default behavior (ItemHomeLibrary) is applied correctly - The correct branch (item homebranch) is recorded in accountlines This improves test coverage and prevents regression of the fix for uninitialized value warnings. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
30510e1d0a
commit
300f121b66
|
|
@ -679,7 +679,7 @@ subtest "C4::Accounts::chargelostitem tests" => sub {
|
|||
my $procfee;
|
||||
|
||||
subtest "Bug 35612: chargelostitem records branch context in accountlines.branchcode" => sub {
|
||||
plan tests => 7;
|
||||
plan tests => 8;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'LostChargesControl', 'ItemHomeLibrary' );
|
||||
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );
|
||||
|
|
@ -809,6 +809,30 @@ subtest "C4::Accounts::chargelostitem tests" => sub {
|
|||
1,
|
||||
"Dedupes LOST charges for same itemnumber + issue_id (no item_id regression)"
|
||||
);
|
||||
|
||||
# Test undefined LostChargesControl (should default to ItemHomeLibrary behavior)
|
||||
Koha::Account::Lines->search(
|
||||
{ borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST' } )
|
||||
->delete;
|
||||
|
||||
t::lib::Mocks::mock_preference( 'LostChargesControl', undef );
|
||||
t::lib::Mocks::mock_preference( 'HomeOrHoldingBranch', 'homebranch' );
|
||||
|
||||
C4::Accounts::chargelostitem(
|
||||
$patron->borrowernumber, $item->itemnumber, 6.12, "Lost test undefined pref",
|
||||
{ issue_id => $issue_id }
|
||||
);
|
||||
|
||||
$lost = Koha::Account::Lines->find(
|
||||
{
|
||||
borrowernumber => $patron->borrowernumber, itemnumber => $item->itemnumber, debit_type_code => 'LOST',
|
||||
issue_id => $issue_id
|
||||
}
|
||||
);
|
||||
is(
|
||||
$lost->branchcode, $lib_home,
|
||||
"LOST uses item homebranch when LostChargesControl is undefined (defaults to ItemHomeLibrary)"
|
||||
);
|
||||
};
|
||||
|
||||
subtest "fee application tests" => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue