Bugzilla – Attachment 130718 Details for
Bug 30072
Add more holds hooks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30072: Unit tests
Bug-30072-Unit-tests.patch (text/plain), 3.22 KB, created by
Martin Renvoize (ashimema)
on 2022-02-17 11:44:00 UTC
(
hide
)
Description:
Bug 30072: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-02-17 11:44:00 UTC
Size:
3.22 KB
patch
obsolete
>From d513a98218934ad7bff14d6239a052d0fa9e5e43 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 11 Feb 2022 15:28:10 -0300 >Subject: [PATCH] Bug 30072: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Plugins/Holds_hooks.t | 65 ++++++++++++++++++++++- > t/lib/plugins/Koha/Plugin/Test.pm | 10 ++++ > 2 files changed, 74 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Plugins/Holds_hooks.t b/t/db_dependent/Koha/Plugins/Holds_hooks.t >index 2e40b9d939..2f56ce1081 100755 >--- a/t/db_dependent/Koha/Plugins/Holds_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Holds_hooks.t >@@ -16,7 +16,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::MockModule; > use Test::Warn; > >@@ -80,3 +80,66 @@ subtest 'after_hold_create() hook tests' => sub { > $schema->storage->txn_rollback; > Koha::Plugins::Methods->delete; > }; >+ >+subtest 'Koha::Hold tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $plugins = Koha::Plugins->new; >+ $plugins->InstallPlugins; >+ >+ my $plugin = Koha::Plugin::Test->new->enable; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ # Reduce noise >+ t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); >+ t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); >+ >+ my $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ } >+ } >+ ); >+ >+ warning_like { >+ $hold->fill; >+ } >+ qr/after_hold_action called with action: fill, ref: Koha::Old::Hold/, >+ '->fill calls the after_hold_action hook'; >+ >+ $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ } >+ } >+ ); >+ >+ warning_like { >+ $hold->suspend_hold; >+ } >+ qr/after_hold_action called with action: suspend, ref: Koha::Hold/, >+ '->suspend_hold calls the after_hold_action hook'; >+ >+ warning_like { >+ $hold->resume; >+ } >+ qr/after_hold_action called with action: resume, ref: Koha::Hold/, >+ '->resume calls the after_hold_action hook'; >+ >+ warning_like { >+ $hold->cancel; >+ } >+ qr/after_hold_action called with action: cancel, ref: Koha::Old::Hold/, >+ '->cancel calls the after_hold_action hook'; >+ >+ $schema->storage->txn_rollback; >+ Koha::Plugins::Methods->delete; >+}; >diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm >index c52064c199..9b135e2d2b 100644 >--- a/t/lib/plugins/Koha/Plugin/Test.pm >+++ b/t/lib/plugins/Koha/Plugin/Test.pm >@@ -206,6 +206,16 @@ sub after_circ_action { > } > } > >+sub after_hold_action { >+ my ( $self, $params ) = @_; >+ >+ my $action = $params->{action}; >+ my $hold = $params->{payload}->{hold}; >+ >+ Koha::Exceptions::Exception->throw( >+ "after_hold_action called with action: $action, ref: " . ref($hold) ); >+} >+ > sub api_routes { > my ( $self, $args ) = @_; > >-- >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 30072
:
130517
|
130518
|
130519
|
130522
|
130523
|
130524
|
130621
|
130622
|
130623
|
130624
| 130718 |
130719
|
130720
|
130721
|
130722
|
130723
|
131366
|
134005