Bugzilla – Attachment 109371 Details for
Bug 24147
Objects.t is failing randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24147: Don't assume search_related will return ordered values
Bug-24147-Dont-assume-searchrelated-will-return-or.patch (text/plain), 3.98 KB, created by
Kyle M Hall (khall)
on 2020-08-31 15:22:27 UTC
(
hide
)
Description:
Bug 24147: Don't assume search_related will return ordered values
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-08-31 15:22:27 UTC
Size:
3.98 KB
patch
obsolete
>From 7ef157b51f5a17b0fa153b61e4f480d435f124ad Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 20 Aug 2020 14:32:43 +0200 >Subject: [PATCH] Bug 24147: Don't assume search_related will return ordered > values > >This test is failing randomly because it assume the order is always the >same. But it's not. > >Note: Koha::Objects->search_related is never used , last use removed from > commit 9aa724cdf29a57bc91e42b240b5bcd19e3814ada > Bug 19599: Speed anonymise_issue_history up >We should keep it however IMO > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/Objects.t | 51 ++++++++++++++++++++++++++--------- > 1 file changed, 39 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 5c35546667..76e0393485 100644 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -139,21 +139,48 @@ subtest 'find' => sub { > }; > > subtest 'search_related' => sub { >- plan tests => 8; >+ plan tests => 6; > my $builder = t::lib::TestBuilder->new; > my $patron_1 = $builder->build( { source => 'Borrower' } ); > my $patron_2 = $builder->build( { source => 'Borrower' } ); >- my $libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); >- is( ref( $libraries ), 'Koha::Libraries', 'Koha::Objects->search_related should return an instanciated Koha::Objects-based object' ); >- is( $libraries->count, 2, 'Koha::Objects->search_related should work as expected' ); >- is( $libraries->next->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); >- is( $libraries->next->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); >- >- my @libraries = Koha::Patrons->search( { -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] } } )->search_related('branchcode'); >- is( ref( $libraries[0] ), 'Koha::Library', 'Koha::Objects->search_related should return a list of Koha::Object-based objects' ); >- is( scalar(@libraries), 2, 'Koha::Objects->search_related should work as expected' ); >- is( $libraries[0]->branchcode, $patron_1->{branchcode}, 'Koha::Objects->search_related should work as expected' ); >- is( $libraries[1]->branchcode, $patron_2->{branchcode}, 'Koha::Objects->search_related should work as expected' ); >+ my $libraries = Koha::Patrons->search( >+ { >+ -or => { >+ borrowernumber => >+ [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] >+ } >+ } >+ )->search_related('branchcode'); >+ is( ref($libraries), 'Koha::Libraries', >+ 'Koha::Objects->search_related should return an instanciated Koha::Objects-based object' >+ ); >+ is( $libraries->count, 2, >+ 'Koha::Objects->search_related should work as expected' ); >+ ok( eq_array( >+ [ $libraries->get_column('branchcode') ], >+ [ $patron_1->{branchcode}, $patron_2->{branchcode} ] ), >+ 'Koha::Objects->search_related should work as expected' >+ ); >+ >+ my @libraries = Koha::Patrons->search( >+ { >+ -or => { >+ borrowernumber => >+ [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber} ] >+ } >+ } >+ )->search_related('branchcode'); >+ is( >+ ref( $libraries[0] ), 'Koha::Library', >+ 'Koha::Objects->search_related should return a list of Koha::Object-based objects' >+ ); >+ is( scalar(@libraries), 2, >+ 'Koha::Objects->search_related should work as expected' ); >+ ok( eq_array( >+ [ map { $_->branchcode } @libraries ], >+ [ $patron_1->{branchcode}, $patron_2->{branchcode} ] ), >+ 'Koha::Objects->search_related should work as expected' >+ ); > }; > > subtest 'single' => sub { >-- >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 24147
:
108735
|
109371
|
109381