Bug 19130: Remove ->search() overloading and adjust tests

This patch removes the custom ->search() function. Tests are adjusted
so the results from ->search() calls are not expected to return in the
previously hardcoded order.

To test:
- Apply this patch
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/db_dependent/Bookseller.t
=> SUCCESS: Tests pass
- Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomás Cohen Arazi 2017-08-22 12:01:24 -03:00 committed by Jonathan Druart
parent 249e721ba4
commit 7e4ce56b27
2 changed files with 27 additions and 16 deletions

View file

@ -1,35 +1,46 @@
package Koha::Acquisition::Booksellers;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Acquisition::Bookseller;
use base qw( Koha::Objects );
use Koha::Acquisition::Bookseller;
=head1 NAME
sub search {
my ( $self, $params, $attributes ) = @_;
Koha::Acquisition::Booksellers Object set class
=head1 API
while ( my ( $field, $value ) = each %$params ) {
if ( $field eq 'name' ) {
# Use "like" if search on name
$params->{name} = { -like => "%$value%" };
}
}
=head2 Class Methods
$attributes->{order_by} ||= { -asc => 'name' };
=head3 _type (internal)
return $self->SUPER::search( $params, $attributes );
}
=cut
sub _type {
return 'Aqbookseller';
}
=head3 object_class (internal)
=cut
sub object_class {
return 'Koha::Acquisition::Bookseller';
}

View file

@ -129,7 +129,7 @@ for my $bookseller ( @booksellers ) {
$sample_supplier1->{id} = $id_supplier1;
is( scalar(@booksellers), $count + 2, "Get Supplier1 and Supplier2" );
my @tab = ( $sample_supplier1, $sample_supplier2 );
my @tab = ( $sample_supplier2, $sample_supplier1 );
is_deeply( \@booksellers, \@tab,
"Returns right fields of Supplier1 and Supplier2" );