From 4be8c9d28c0cc977872ff9f461f8622e9ec70e81 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 Aug 2020 17:37:45 +0200 Subject: [PATCH] Bug 19036: Add missing test --- t/db_dependent/Koha/Account.t | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index 0dfc5f4400..493e1ba639 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -1051,8 +1051,8 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub { $schema->storage->txn_rollback; }; -subtest 'Koha::Account::pay() generates credit number' => sub { - plan tests => 37; +subtest 'Koha::Account::pay() generates credit number (Koha::Account::Line->store)' => sub { + plan tests => 38; $schema->storage->txn_begin; @@ -1062,6 +1062,7 @@ subtest 'Koha::Account::pay() generates credit number' => sub { my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $account = $patron->account; + #t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode }); my $context = Test::MockModule->new('C4::Context'); $context->mock( 'userenv', { branch => $library->id } ); @@ -1109,5 +1110,16 @@ subtest 'Koha::Account::pay() generates credit number' => sub { $accountline = Koha::Account::Lines->find($accountlines_id); is($accountline->credit_number, undef); + throws_ok { + Koha::Account::Line->new( + { + credit_type_code => $credit_type->code, + credit_number => 42 + } + )->store; + } + qr/AutoCreditNumber is enabled but credit_number is already defined!/, + 'Croaked on bad call to store'; + $schema->storage->txn_rollback; }; -- 2.20.1