From 7e4ce56b27025b05ee572100529eaa4f28e0933c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 22 Aug 2017 12:01:24 -0300 Subject: [PATCH] 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 Signed-off-by: Jonathan Druart --- Koha/Acquisition/Booksellers.pm | 41 ++++++++++++++++++++++++++--------------- t/db_dependent/Bookseller.t | 2 +- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Koha/Acquisition/Booksellers.pm b/Koha/Acquisition/Booksellers.pm index 5fa3540226..1d1eb48a31 100644 --- a/Koha/Acquisition/Booksellers.pm +++ b/Koha/Acquisition/Booksellers.pm @@ -1,35 +1,46 @@ package Koha::Acquisition::Booksellers; -use Modern::Perl; +# 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 Carp; +use Modern::Perl; -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'; } diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t index 96e08377ac..94293ac2ce 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -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" ); -- 2.11.0