From 2138e5af52fa27eab17c9ec5adda4d73b837a71f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 1 Oct 2020 14:33:46 +0100 Subject: [PATCH] Bug 26506: (QA follow-up) Add Unit Test Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit ae475eb15a4b1c8b5c49c1c4f79388c9e1d7686a) Signed-off-by: Lucas Gass --- t/db_dependent/Koha/Account.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index ebab6b0ae5..791ab3adcd 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -671,7 +671,7 @@ subtest 'reconcile_balance' => sub { subtest 'pay() tests' => sub { - plan tests => 3; + plan tests => 5; $schema->storage->txn_begin; @@ -712,6 +712,19 @@ subtest 'pay() tests' => sub { # Disable cash registers t::lib::Mocks::mock_preference( 'UseCashRegisters', 1 ); + # Undef userenv + $context->mock( 'userenv', undef ); + my $result = $account->pay( + { + amount => 20, + payment_Type => 'CASH', + interface => 'intranet' + } + ); + ok($result, "Koha::Account->pay functions without a userenv"); + my $payment = Koha::Account::Lines->find({accountlines_id => $result->{payment_id}}); + is($payment->manager_id, undef, "manager_id left undefined when no userenv found"); + $schema->storage->txn_rollback; }; -- 2.39.5