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 commit9aa724cdf2Bug 19599: Speed anonymise_issue_history up We should keep it however IMO Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commite10dc50328) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commite550f25a01) Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
This commit is contained in:
parent
4eb56562a5
commit
c9d3eb03ba
|
|
@ -142,21 +142,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), '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' );
|
||||
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[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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue