Bugzilla – Attachment 117206 Details for
Bug 27071
Hold pickup library match not enforced correctly on intranet when using hold groups
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27071: More tests for Koha::Library->validate_hold_sibling
Bug-27071-More-tests-for-KohaLibrary-validateholds.patch (text/plain), 4.66 KB, created by
Martin Renvoize (ashimema)
on 2021-02-23 13:41:05 UTC
(
hide
)
Description:
Bug 27071: More tests for Koha::Library->validate_hold_sibling
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-02-23 13:41:05 UTC
Size:
4.66 KB
patch
obsolete
>From 7ca48ce445246b92e57a6bd5a961155d03112c4f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 24 Nov 2020 11:55:14 -0300 >Subject: [PATCH] Bug 27071: More tests for > Koha::Library->validate_hold_sibling > >This patch adds tests for more than one non-same sibling libraries in >the hold group. Tests pass which means it is working as expected. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Libraries.t >=> SUCCESS: Tests pass > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Libraries.t | 41 +++++++++++++++++++++++++-------- > 1 file changed, 32 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Koha/Libraries.t b/t/db_dependent/Koha/Libraries.t >index b5e8d93b2a..4bed00d852 100755 >--- a/t/db_dependent/Koha/Libraries.t >+++ b/t/db_dependent/Koha/Libraries.t >@@ -247,33 +247,56 @@ subtest 'cash_registers' => sub { > > subtest 'get_hold_libraries and validate_hold_sibling' => sub { > >- plan tests => 5; >+ plan tests => 12; > > $schema->storage->txn_begin; > > my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); > my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); > my $library3 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library4 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library5 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); >+ my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); >+ # G1 >+ $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } ); >+ $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } ); >+ # G2 >+ $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } ); >+ $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } ); >+ $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library5->branchcode } } ); >+ >+ my @hold_libraries_1 = ($library1, $library2); >+ my @hold_libraries_2 = ($library3, $library4, $library5); > >- my $root = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); >- my $g1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root->id, branchcode => $library1->branchcode } } ); >- my $g2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root->id, branchcode => $library2->branchcode } } ); >+ my @result = $library1->get_hold_libraries(); >+ # library1 and library2 are siblings >+ is(scalar(@result), 2, 'get_hold_libraries returns 2 libraries'); > >- my @hold_libraries = ($library1, $library2); >+ my %map = map {$_->branchcode, 1} @result; > >- my @result = $library1->get_hold_libraries(); >+ foreach my $hold_library ( @hold_libraries_1 ) { >+ ok(exists $map{$hold_library->branchcode}, 'library in hold group'); >+ } > >- ok(scalar(@result) == 2, 'get_hold_libraries returns 2 libraries'); >+ @result = $library3->get_hold_libraries(); >+ # library3, library4 and library5 are siblings >+ is(scalar(@result), 3, 'get_hold_libraries returns 3 libraries'); > >- my %map = map {$_->branchcode, 1} @result; >+ %map = map {$_->branchcode, 1} @result; > >- foreach my $hold_library ( @hold_libraries ) { >+ foreach my $hold_library ( @hold_libraries_2 ) { > ok(exists $map{$hold_library->branchcode}, 'library in hold group'); > } > > ok($library1->validate_hold_sibling( { branchcode => $library2->branchcode } ), 'Library 2 is a valid hold sibling'); > ok(!$library1->validate_hold_sibling( { branchcode => $library3->branchcode } ), 'Library 3 is not a valid hold sibling'); > >+ ok($library3->validate_hold_sibling( { branchcode => $library4->branchcode } ), 'Library 4 is a valid hold sibling'); >+ ok($library3->validate_hold_sibling( { branchcode => $library5->branchcode } ), 'Library 5 is a valid hold sibling'); >+ ok(!$library3->validate_hold_sibling( { branchcode => $library2->branchcode } ), 'Library 2 is not a valid hold sibling'); >+ > $schema->storage->txn_rollback; > > }; >-- >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 27071
:
113928
|
113929
|
113963
|
116599
|
116600
|
116601
|
116602
|
116603
|
117140
|
117141
|
117142
|
117143
|
117144
|
117145
|
117184
|
117185
|
117186
|
117187
|
117188
|
117189
|
117204
|
117205
| 117206 |
117207
|
117208
|
117209