From 8924ee175888c9a9efdcb951ce7ed01bc92bc38d Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 12 Nov 2020 13:34:33 -0500 Subject: [PATCH] Bug 26352: Add unit test Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t | 7 ++++++- t/lib/Koha/Plugin/Test.pm | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t index 5a6b156f2a..684c7d8dfa 100755 --- a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t +++ b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t @@ -42,7 +42,7 @@ t::lib::Mocks::mock_config( 'enable_plugins', 1 ); subtest '() hook tests' => sub { - plan tests => 1; + plan tests => 2; $schema->storage->txn_begin; @@ -52,6 +52,11 @@ subtest '() hook tests' => sub { my $plugin = Koha::Plugin::Test->new->enable; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $cardnumber = $patron->cardnumber; + + warning_like { $patron->store(); } + qr/patron_barcode_transform called with parameter: $cardnumber/, + 'Koha::Patron::store calls the patron_barcode_transform hook'; t::lib::Mocks::mock_userenv( { diff --git a/t/lib/Koha/Plugin/Test.pm b/t/lib/Koha/Plugin/Test.pm index 24217d098f..137d2355a8 100644 --- a/t/lib/Koha/Plugin/Test.pm +++ b/t/lib/Koha/Plugin/Test.pm @@ -98,6 +98,11 @@ sub item_barcode_transform { Koha::Exceptions::Exception->throw("item_barcode_transform called with parameter: $barcode"); } +sub patron_barcode_transform { + my ( $self, $barcode ) = @_; + Koha::Exceptions::Exception->throw("patron_barcode_transform called with parameter: $barcode"); +} + sub configure { my ( $self, $args ) = @_; return "Koha::Plugin::Test::configure"; -- 2.24.1 (Apple Git-126)