Lines 40-53
my $builder = t::lib::TestBuilder->new;
Link Here
|
40 |
|
40 |
|
41 |
t::lib::Mocks::mock_config( 'enable_plugins', 1 ); |
41 |
t::lib::Mocks::mock_config( 'enable_plugins', 1 ); |
42 |
|
42 |
|
43 |
subtest '() hook tests' => sub { |
43 |
subtest 'patron_barcode_transform() and item_barcode_transform() hook tests' => sub { |
44 |
|
44 |
|
45 |
plan tests => 4; |
45 |
plan tests => 6; |
46 |
|
46 |
|
47 |
$schema->storage->txn_begin; |
47 |
$schema->storage->txn_begin; |
48 |
|
48 |
|
|
|
49 |
# Avoid testing useless warnings |
50 |
my $test_plugin = Test::MockModule->new('Koha::Plugin::Test'); |
51 |
$test_plugin->mock( 'after_item_action', undef ); |
52 |
$test_plugin->mock( 'after_biblio_action', undef ); |
53 |
|
49 |
my $plugins = Koha::Plugins->new; |
54 |
my $plugins = Koha::Plugins->new; |
50 |
$plugins->InstallPlugins; |
55 |
|
|
|
56 |
warnings_are |
57 |
{ $plugins->InstallPlugins; } |
58 |
[ "Calling 'install' died for plugin Koha::Plugin::BrokenInstall", |
59 |
"Calling 'upgrade' died for plugin Koha::Plugin::BrokenUpgrade" ]; |
60 |
|
51 |
C4::Context->dbh->do("DELETE FROM plugin_methods WHERE plugin_class LIKE '%TestBarcodes%'"); |
61 |
C4::Context->dbh->do("DELETE FROM plugin_methods WHERE plugin_class LIKE '%TestBarcodes%'"); |
52 |
|
62 |
|
53 |
my $plugin = Koha::Plugin::Test->new->enable; |
63 |
my $plugin = Koha::Plugin::Test->new->enable; |
Lines 81-98
subtest '() hook tests' => sub {
Link Here
|
81 |
} |
91 |
} |
82 |
); |
92 |
); |
83 |
|
93 |
|
84 |
# Avoid testing useless warnings |
94 |
my $item; |
85 |
my $test_plugin = Test::MockModule->new('Koha::Plugin::Test'); |
95 |
warning_like { $item = $builder->build_sample_item(); } |
86 |
$test_plugin->mock( 'after_item_action', undef ); |
96 |
qr/Plugin error \(Test Plugin\): item_barcode_transform called with parameter: /, |
87 |
$test_plugin->mock( 'after_biblio_action', undef ); |
97 |
'Koha::Item->store calls the item_barcode_transform hook'; |
88 |
|
98 |
|
89 |
my $biblio = $builder->build_sample_biblio(); |
99 |
$item->barcode('THISISATEST'); |
90 |
my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
|
|
91 |
$item_1->barcode('THISISATEST'); |
92 |
|
100 |
|
93 |
warning_like { $item_1->store(); } |
101 |
warning_is { $item->store(); } |
94 |
qr/item_barcode_transform called with parameter: THISISATEST/, |
102 |
'Plugin error (Test Plugin): item_barcode_transform called with parameter: THISISATEST', |
95 |
'AddReserve calls the after_hold_create hook'; |
103 |
'Koha::Item->store calls the item_barcode_transform hook'; |
96 |
|
104 |
|
97 |
$schema->storage->txn_rollback; |
105 |
$schema->storage->txn_rollback; |
98 |
Koha::Plugins::Methods->delete; |
106 |
Koha::Plugins::Methods->delete; |