3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, see <http://www.gnu.org/licenses>.
19 use Test::More tests => 4;
25 use Koha::Account qw( add_credit );
28 use t::lib::TestBuilder;
31 # Mock pluginsdir before loading Plugins module
32 my $path = dirname(__FILE__) . '/../../../lib/plugins';
33 t::lib::Mocks::mock_config( 'pluginsdir', $path );
35 use_ok('Koha::Plugins');
36 use_ok('Koha::Plugins::Handler');
37 use_ok('Koha::Plugin::Test');
40 my $schema = Koha::Database->new->schema;
41 my $builder = t::lib::TestBuilder->new;
43 t::lib::Mocks::mock_config( 'enable_plugins', 1 );
45 subtest 'Koha::Account tests' => sub {
49 $schema->storage->txn_begin;
51 my $plugins = Koha::Plugins->new;
52 $plugins->InstallPlugins;
54 my $plugin = Koha::Plugin::Test->new->enable;
56 my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
58 my $account = $patron->account;
60 $account->add_credit({ amount => 20, interface => 'commandline', type => 'WRITEOFF'});
62 qr/after_account_action called with action: add_credit, type: writeoff, ref: Koha::Account::Line/,
63 '->add_credit calls the after_account_action hook with type writeoff';
67 $account->add_credit({ amount => 10, interface => 'commandline', type => 'PAYMENT'});
69 qr/after_account_action called with action: add_credit, type: payment, ref: Koha::Account::Line/,
70 '->add_credit calls the after_account_action hook with type payment';
72 Koha::Plugins::Methods->delete;
73 $schema->storage->txn_rollback;