|
Lines 16-23
Link Here
|
| 16 |
|
16 |
|
| 17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
| 18 |
|
18 |
|
| 19 |
use Test::More tests => 5; |
19 |
use Test::More tests => 6; |
| 20 |
use Test::Exception; |
20 |
use Test::Exception; |
|
|
21 |
use Test::Warn; |
| 21 |
|
22 |
|
| 22 |
use File::Basename; |
23 |
use File::Basename; |
| 23 |
|
24 |
|
|
Lines 91-94
subtest 'check_password hook tests' => sub {
Link Here
|
| 91 |
Koha::Plugins::Methods->delete; |
92 |
Koha::Plugins::Methods->delete; |
| 92 |
}; |
93 |
}; |
| 93 |
|
94 |
|
|
|
95 |
subtest 'after_patron_action hook tests' => sub { |
| 96 |
|
| 97 |
plan tests => 4; |
| 98 |
|
| 99 |
$schema->storage->txn_begin; |
| 100 |
|
| 101 |
my $plugins = Koha::Plugins->new; |
| 102 |
$plugins->InstallPlugins; |
| 103 |
|
| 104 |
my $plugin = Koha::Plugin::Test->new->enable; |
| 105 |
|
| 106 |
ok( $plugin->can('after_patron_action'), 'Test plugin can after_patron_action' ); |
| 107 |
|
| 108 |
my $library = $builder->build( { source => 'Branch' } ); |
| 109 |
my $category = $builder->build( { source => 'Category' } ); |
| 110 |
my $patron = Koha::Patron->new( |
| 111 |
{ |
| 112 |
cardnumber => 'test_cn_after_patron_action', # Only this cardnumber is set to react to after_patron_action hook |
| 113 |
branchcode => $library->{branchcode}, |
| 114 |
categorycode => $category->{categorycode}, |
| 115 |
} |
| 116 |
); |
| 117 |
|
| 118 |
warning_like { $patron->store->discard_changes; } |
| 119 |
qr/after_patron_action called with action: create, ref: Koha::Patron/, |
| 120 |
'Koha::Patron->store calls the hook with action=create'; |
| 121 |
|
| 122 |
warning_like { $patron->store; } |
| 123 |
qr/after_patron_action called with action: modify, ref: Koha::Patron/, |
| 124 |
'If patron exists, Koha::Patron->store calls the hook with action=modify'; |
| 125 |
|
| 126 |
warning_like { $patron->delete; } |
| 127 |
qr/after_patron_action called with action: delete/, |
| 128 |
'Koha::Patron->delete calls the hook with action=delete'; |
| 129 |
|
| 130 |
$schema->storage->txn_rollback; |
| 131 |
Koha::Plugins::Methods->delete; |
| 132 |
}; |
| 133 |
|
| 94 |
1; |
134 |
1; |