Bugzilla – Attachment 91870 Details for
Bug 23395
batch operations on biblios/items should be able to pass a list of plugins
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23395: Unit tests
Bug-23395-Unit-tests.patch (text/plain), 6.25 KB, created by
Tomás Cohen Arazi (tcohen)
on 2019-07-30 12:53:53 UTC
(
hide
)
Description:
Bug 23395: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2019-07-30 12:53:53 UTC
Size:
6.25 KB
patch
obsolete
>From 7c11ba7278994d978daa11de3f041a2c37055a12 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 29 Jul 2019 16:35:33 -0300 >Subject: [PATCH] Bug 23395: Unit tests > >--- > .../Plugins/Biblio_and_Items_plugin_hooks.t | 98 ++++++++++++++++--- > 1 file changed, 85 insertions(+), 13 deletions(-) > >diff --git a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t >index 99dacec4dd..fbede0fcac 100755 >--- a/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t >+++ b/t/db_dependent/Koha/Plugins/Biblio_and_Items_plugin_hooks.t >@@ -16,8 +16,9 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::Warn; >+use Test::NoWarnings; > > use File::Basename; > >@@ -44,42 +45,113 @@ t::lib::Mocks::mock_config( 'enable_plugins', 1 ); > > subtest 'after_biblio_action() and after_item_action() hooks tests' => sub { > >- plan tests => 6; >+ plan tests => 12; > > $schema->storage->txn_begin; > >+ my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ > my $plugins = Koha::Plugins->new; > $plugins->InstallPlugins; > > my $plugin = Koha::Plugin::Test->new->enable; > >- my $biblio_id; >+ my $biblio_id_1; >+ my $itemnumber_1; > >- warning_like { ( $biblio_id, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '' ); } >+ warning_like { ( $biblio_id_1, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '' ); } > qr/after_biblio_action called with action: create, ref: Koha::Biblio/, > 'AddBiblio calls the hook with action=create'; > >- warning_like { C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id, '' ); } >+ warning_like { C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id_1, '' ); } > qr/after_biblio_action called with action: modify, ref: Koha::Biblio/, > 'ModBiblio calls the hook with action=modify'; > >- my $item; >- warning_like { $item = $builder->build_sample_item({ biblionumber => $biblio_id }); } >- qr/after_item_action called with action: create, ref: Koha::Item/, >- 'AddItem calls the hook with action=create'; >- >- warning_like { C4::Items::ModItem({ location => 'shelves' }, $biblio_id, $item->itemnumber); } >+ warning_like { >+ ( undef, undef, $itemnumber_1 ) = C4::Items::AddItem( >+ { homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ itype => $item_type->itemtype >+ }, >+ $biblio_id_1 >+ ); >+ } >+ qr/after_item_action called with action: create, ref: Koha::Item/, >+ 'AddItem calls the hook with action=create'; >+ >+ warning_like { C4::Items::ModItem({ location => 'shelves' }, $biblio_id_1, $itemnumber_1); } > qr/after_item_action called with action: modify, ref: Koha::Item/, > 'ModItem calls the hook with action=modify'; > >- warning_like { C4::Items::DelItem({ itemnumber => $item->itemnumber }); } >+ warning_like { C4::Items::DelItem({ itemnumber => $itemnumber_1 }); } > qr/after_item_action called with action: delete/, > 'DelItem calls the hook with action=delete, item_id passed'; > >- warning_like { C4::Biblio::DelBiblio( $biblio_id ); } >+ warning_like { C4::Biblio::DelBiblio( $biblio_id_1 ); } > qr/after_biblio_action called with action: delete/, > 'DelBiblio calls the hook with action=delete biblio_id passed'; > >+ my $biblio_id_2; >+ my $itemnumber_2; >+ >+ warning_like { ( $biblio_id_2, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '', { plugins => [ $plugin ] } ); } >+ qr/after_biblio_action called with action: create, ref: Koha::Biblio/, >+ 'AddBiblio calls the hook with action=create'; >+ >+ warning_like { C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id_2, '', undef, [ $plugin ] ); } >+ qr/after_biblio_action called with action: modify, ref: Koha::Biblio/, >+ 'ModBiblio calls the hook with action=modify'; >+ >+ warning_like { >+ ( undef, undef, $itemnumber_2 ) = C4::Items::AddItem( >+ { homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ itype => $item_type->itemtype >+ }, >+ $biblio_id_2, >+ C4::Context->dbh, >+ C4::Biblio::GetFrameworkCode($biblio_id_2), >+ undef, >+ [ $plugin ] >+ ); >+ } >+ qr/after_item_action called with action: create, ref: Koha::Item/, >+ 'AddItem calls the hook with action=create'; >+ >+ warning_like { >+ C4::Items::ModItem( { location => 'shelves' }, >+ $biblio_id_2, $itemnumber_2, { plugins => [$plugin] } ); >+ } >+ qr/after_item_action called with action: modify, ref: Koha::Item/, >+ 'ModItem calls the hook with action=modify'; >+ >+ warning_like { C4::Items::DelItem( { itemnumber => $itemnumber_2, plugins => [ $plugin ] } ); } >+ qr/after_item_action called with action: delete/, >+ 'DelItem calls the hook with action=delete, item_id passed'; >+ >+ warning_like { C4::Biblio::DelBiblio( $biblio_id_2, [ $plugin ] ); } >+ qr/after_biblio_action called with action: delete/, >+ 'DelBiblio calls the hook with action=delete biblio_id passed'; >+ >+ # Call C4::Biblio::{Add|Mod|Del}Biblio with an empty list of plugins, pairing >+ # with Test::NoWarnings to test no warnings are raised by plugins >+ my ( $biblio_id_3, undef ) = C4::Biblio::AddBiblio( MARC::Record->new(), '', { plugins => [] } ); >+ C4::Biblio::ModBiblio( MARC::Record->new(), $biblio_id_3, '', undef, [] ); >+ my ( undef, undef, $itemnumber_3 ) = C4::Items::AddItem( >+ { homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ itype => $item_type->itemtype >+ }, >+ $biblio_id_3, >+ C4::Context->dbh, >+ C4::Biblio::GetFrameworkCode($biblio_id_3), >+ undef, >+ [] >+ ); >+ C4::Items::DelItem( { itemnumber => $itemnumber_3, plugins => [] } ); >+ C4::Biblio::DelBiblio( $biblio_id_3, [] ); >+ > $schema->storage->txn_rollback; > Koha::Plugins::Methods->delete; > }; >-- >2.22.0
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 23395
: 91870 |
91871
|
91872
|
91874