Bug 19036: Add missing test
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 18 Aug 2020 15:37:45 +0000 (17:37 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 20 Aug 2020 10:31:59 +0000 (12:31 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

t/db_dependent/Koha/Account.t

index 0dfc5f4..493e1ba 100755 (executable)
@@ -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;
 };