@@ -, +, @@ --- t/db_dependent/Koha/Account.t | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) --- a/t/db_dependent/Koha/Account.t +++ a/t/db_dependent/Koha/Account.t @@ -158,7 +158,7 @@ subtest 'outstanding_credits() tests' => sub { subtest 'add_credit() tests' => sub { - plan tests => 16; + plan tests => 17; $schema->storage->txn_begin; @@ -231,18 +231,39 @@ subtest 'add_credit() tests' => sub { is( $offset_2->debit_id, undef, 'No debit_id is set for credits' ); my $line_3 = $account->add_credit( - { amount => 20, + { + amount => 20, description => 'Manual credit applied', library_id => $patron->branchcode, user_id => $patron->id, type => 'forgiven', - interface => 'commandline' + interface => 'intranet' } ); is( $schema->resultset('ActionLog')->count(), $action_logs + 2, 'Log was added' ); is( $schema->resultset('Statistic')->count(), $statistics + 2, 'No action added to statistics, because of credit type' ); + # Enable cash registers + t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 ); + throws_ok { + $account->add_credit( + { + amount => 20, + description => 'Cash payment without cash register', + library_id => $patron->branchcode, + user_id => $patron->id, + payment_type => 'CASH', + interface => 'intranet' + } + ); + } + 'Koha::Exceptions::Account::RegisterRequired', + 'Exception thrown if cash regisers are enabled, a CASH payemtn type is used and not register is passed'; + + # Disable cash registers + t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 ); + $schema->storage->txn_rollback; }; --