Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
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 |
8 |
# version. |
9 |
# |
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. |
13 |
# |
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>. |
16 |
|
17 |
use Modern::Perl; |
18 |
|
19 |
use Test::More tests => 4; |
20 |
use Test::MockModule; |
21 |
|
22 |
use File::Basename; |
23 |
|
24 |
use t::lib::Mocks; |
25 |
|
26 |
BEGIN { |
27 |
# Mock pluginsdir before loading Plugins module |
28 |
my $path = dirname(__FILE__) . '/../../../lib'; |
29 |
t::lib::Mocks::mock_config( 'pluginsdir', $path ); |
30 |
|
31 |
use_ok('Koha::Plugins'); |
32 |
use_ok('Koha::Plugins::Handler'); |
33 |
use_ok('Koha::Plugin::Test'); |
34 |
} |
35 |
|
36 |
my $schema = Koha::Database->new->schema; |
37 |
|
38 |
require t::lib::TestBuilder; |
39 |
my $builder = t::lib::TestBuilder->new; |
40 |
|
41 |
t::lib::Mocks::mock_config( 'enable_plugins', 1 ); |
42 |
|
43 |
subtest 'object_store_pre and object_store_post hook tests' => sub { |
44 |
plan tests => 2; |
45 |
|
46 |
$schema->storage->txn_begin; |
47 |
|
48 |
my $plugins = Koha::Plugins->new; |
49 |
$plugins->InstallPlugins; |
50 |
Koha::Plugin::Test->new->enable; |
51 |
|
52 |
my $item = $builder->build_sample_item(); |
53 |
|
54 |
is($item->itemnotes, 'notes added by object_store_pre'); |
55 |
is($item->itemnotes_nonpublic, 'notes added by object_store_post'); |
56 |
|
57 |
$schema->storage->txn_rollback; |
58 |
}; |