Bugzilla – Attachment 115170 Details for
Bug 26352
Add plugin hooks to transform patron barcodes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26352: (QA follow-up) Add additional tests
Bug-26352-QA-follow-up-Add-additional-tests.patch (text/plain), 3.50 KB, created by
Kyle M Hall (khall)
on 2021-01-14 15:58:45 UTC
(
hide
)
Description:
Bug 26352: (QA follow-up) Add additional tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-01-14 15:58:45 UTC
Size:
3.50 KB
patch
obsolete
>From 84733ddc522f9322917929234ee93d7fb5613788 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 20 Nov 2020 14:13:39 +0000 >Subject: [PATCH] Bug 26352: (QA follow-up) Add additional tests > >This patch adds additional unit tests for autoMemberNum handling and >corrects the implimentation there. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Patron.pm | 2 +- > .../Koha/Plugins/Barcode_transform_hooks.t | 25 +++++++++++++++---- > t/lib/Koha/Plugin/Test.pm | 1 + > 3 files changed, 22 insertions(+), 6 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 4dfe7773ac..97e0de03b8 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -112,7 +112,7 @@ Autogenerate next cardnumber from highest value found in database > sub fixup_cardnumber { > my ( $self ) = @_; > >- my ( $max ) = Koha::Plugins->call( 'patron_barcode_transform', $self ) || undef; >+ my ( $max ) = Koha::Plugins->call( 'patron_barcode_transform', $self->cardnumber ) || undef; > > $max ||= Koha::Patrons->search({ > cardnumber => {-regexp => '^-?[0-9]+$'} >diff --git a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t >index 684c7d8dfa..7f3682b993 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 => 2; >+ plan tests => 4; > > $schema->storage->txn_begin; > >@@ -51,12 +51,27 @@ subtest '() hook tests' => sub { > > my $plugin = Koha::Plugin::Test->new->enable; > >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >- my $cardnumber = $patron->cardnumber; >+ my $patron = $builder->build_object( >+ { class => 'Koha::Patrons', value => { cardnumber => undef } } ); > >+ t::lib::Mocks::mock_preference( 'autoMemberNum', 1 ); >+ warnings_like { $patron->store(); } >+ [ >+ qr/patron_barcode_transform called with parameter: /, >+ qr/patron_barcode_transform called with parameter: / >+ ], >+ 'Koha::Patron::store calls the patron_barcode_transform hook twice when autoMemberNum is enabled and cardnumber is undefined'; >+ >+ $patron->cardnumber('TEST'); >+ warning_like { $patron->store(); } >+ qr/patron_barcode_transform called with parameter: TEST/, >+ 'Koha::Patron::store calls the patron_barcode_transform hook once when autoMemberNum is enabled and cardnumber is set'; >+ >+ t::lib::Mocks::mock_preference( 'autoMemberNum', 0 ); >+ $patron->cardnumber(undef); > warning_like { $patron->store(); } >- qr/patron_barcode_transform called with parameter: $cardnumber/, >- 'Koha::Patron::store calls the patron_barcode_transform hook'; >+ qr/patron_barcode_transform called with parameter: /, >+ 'Koha::Patron::store calls the patron_barcode_transform hook once when autoMemberNum is disabled and cardnumber is undefined'; > > t::lib::Mocks::mock_userenv( > { >diff --git a/t/lib/Koha/Plugin/Test.pm b/t/lib/Koha/Plugin/Test.pm >index 137d2355a8..26c1d36109 100644 >--- a/t/lib/Koha/Plugin/Test.pm >+++ b/t/lib/Koha/Plugin/Test.pm >@@ -100,6 +100,7 @@ sub item_barcode_transform { > > sub patron_barcode_transform { > my ( $self, $barcode ) = @_; >+ $barcode //= ''; > Koha::Exceptions::Exception->throw("patron_barcode_transform called with parameter: $barcode"); > } > >-- >2.24.1 (Apple Git-126)
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 26352
:
109533
|
109547
|
113579
|
113580
|
113880
|
113885
|
113886
|
113887
|
113888
|
115167
|
115168
|
115169
|
115170
|
115171
|
118691
|
118692
|
118693
|
118694
|
118695
|
122428
|
122429
|
122430
|
122431
|
122432