Bugzilla – Attachment 126274 Details for
Bug 28211
Replace use of call_recursive() with call()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28211: (QA follow-up) Add unit tests
Bug-28211-QA-follow-up-Add-unit-tests.patch (text/plain), 3.67 KB, created by
Kyle M Hall (khall)
on 2021-10-14 11:58:13 UTC
(
hide
)
Description:
Bug 28211: (QA follow-up) Add unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-10-14 11:58:13 UTC
Size:
3.67 KB
patch
obsolete
>From 8e693d6f1e34e21950ac8b6b40c8555c0783d66b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 14 Oct 2021 11:57:55 +0000 >Subject: [PATCH] Bug 28211: (QA follow-up) Add unit tests > >--- > t/db_dependent/Koha/Plugins/Plugins.t | 7 ++- > t/lib/Koha/Plugin/Test.pm | 4 +- > t/lib/Koha/Plugin/TestItemBarcodeTransform.pm | 44 +++++++++++++++++++ > 3 files changed, 52 insertions(+), 3 deletions(-) > create mode 100644 t/lib/Koha/Plugin/TestItemBarcodeTransform.pm > >diff --git a/t/db_dependent/Koha/Plugins/Plugins.t b/t/db_dependent/Koha/Plugins/Plugins.t >index 3f48adb1c36..6a5d022e33b 100755 >--- a/t/db_dependent/Koha/Plugins/Plugins.t >+++ b/t/db_dependent/Koha/Plugins/Plugins.t >@@ -25,7 +25,7 @@ use File::Temp qw( tempdir tempfile ); > use FindBin qw($Bin); > use Module::Load::Conditional qw(can_load); > use Test::MockModule; >-use Test::More tests => 60; >+use Test::More tests => 61; > use Test::Warn; > > use C4::Context; >@@ -43,6 +43,7 @@ BEGIN { > use_ok('Koha::Plugins::Handler'); > use_ok('Koha::Plugins::Base'); > use_ok('Koha::Plugin::Test'); >+ use_ok('Koha::Plugin::TestItemBarcodeTransform'); > } > > my $schema = Koha::Database->new->schema; >@@ -100,9 +101,11 @@ subtest 'more call() tests' => sub { > $plugin->enable(); > } > >+ # Barcode is multipled by 2 by Koha::Plugin::Test, and again by 4 by Koha::Plugin::TestItemBarcodeTransform >+ # showing that call has passed the same ref to multiple plugins to operate on > my $bc = 1; > Koha::Plugins->call('item_barcode_transform', \$bc); >- is( $bc, 4, "Got expected response" ); >+ is( $bc, 8, "Got expected response" ); > > my $cn = 'abcd'; > Koha::Plugins->call('item_barcode_transform', \$cn); >diff --git a/t/lib/Koha/Plugin/Test.pm b/t/lib/Koha/Plugin/Test.pm >index cd5b7cbe553..e90648ea6bb 100644 >--- a/t/lib/Koha/Plugin/Test.pm >+++ b/t/lib/Koha/Plugin/Test.pm >@@ -96,7 +96,9 @@ sub intranet_js { > sub item_barcode_transform { > my ( $self, $barcode ) = @_; > my $param = $$barcode; >- $$barcode = 4 if "$$barcode" eq 1; >+ if ( Scalar::Util::looks_like_number( $$barcode ) ) { >+ $$barcode = $$barcode * 2 >+ } > Koha::Exceptions::Exception->throw("item_barcode_transform called with parameter: $param"); > } > >diff --git a/t/lib/Koha/Plugin/TestItemBarcodeTransform.pm b/t/lib/Koha/Plugin/TestItemBarcodeTransform.pm >new file mode 100644 >index 00000000000..32f0b895500 >--- /dev/null >+++ b/t/lib/Koha/Plugin/TestItemBarcodeTransform.pm >@@ -0,0 +1,44 @@ >+package Koha::Plugin::TestItemBarcodeTransform; >+ >+## It's good practice to use Modern::Perl >+use Modern::Perl; >+ >+use Koha::Exceptions::Exception; >+use Koha::Plugins::Tab; >+ >+use Mojo::JSON qw( decode_json ); >+ >+## Required for all plugins >+use base qw(Koha::Plugins::Base); >+ >+our $VERSION = 1.01; >+our $metadata = { >+ name => 'Test Plugin for item_barcode_transform', >+ author => 'Kyle M Hall', >+ description => 'Test plugin', >+ date_authored => '2021-10-14', >+ date_updated => '2021-10-14', >+ minimum_version => '21.11', >+ maximum_version => undef, >+ version => $VERSION, >+}; >+ >+## This is the minimum code required for a plugin's 'new' method >+## More can be added, but none should be removed >+sub new { >+ my ( $class, $args ) = @_; >+ $args->{'metadata'} = $metadata; >+ my $self = $class->SUPER::new($args); >+ return $self; >+} >+ >+sub item_barcode_transform { >+ my ( $self, $barcode ) = @_; >+ my $param = $$barcode; >+ if ( Scalar::Util::looks_like_number( $$barcode ) ) { >+ $$barcode = $$barcode * 4 >+ } >+ Koha::Exceptions::Exception->throw("item_barcode_transform called with parameter: $param"); >+} >+ >+1; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28211
:
120120
|
120875
|
120882
|
120883
|
122425
|
122426
|
122427
|
125892
|
125926
|
125927
|
125928
| 126274 |
126471
|
126497