Bug 27333: Throw the right exceptions
If parameters are missing, we need to throw Koha::Exceptions::MissingParameter exceptions. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Club/Hold.t => FAIL: Tests fail because the method doesn't throw the right exceptions 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commitc5f3fdcc15) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit8bbc4514b7) Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> (cherry picked from commit7a611d3ba3) Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
This commit is contained in:
parent
5d67f204e6
commit
a04e696df9
|
|
@ -26,6 +26,7 @@ use Koha::Database;
|
|||
use Koha::Club::Template::Fields;
|
||||
|
||||
use base qw(Koha::Object);
|
||||
use Koha::Exceptions;
|
||||
use Koha::Exceptions::ClubHold;
|
||||
use Koha::Club::Hold::PatronHold;
|
||||
use Koha::Clubs;
|
||||
|
|
@ -53,8 +54,14 @@ Class (static) method that returns a new Koha::Club::Hold instance
|
|||
sub add {
|
||||
my ( $params ) = @_;
|
||||
|
||||
Koha::Exceptions::ClubHold->throw()
|
||||
unless $params->{club_id} && $params->{biblio_id};
|
||||
# check for mandatory params
|
||||
my @mandatory = ( 'biblio_id', 'club_id' );
|
||||
for my $param (@mandatory) {
|
||||
unless ( defined( $params->{$param} ) ) {
|
||||
Koha::Exceptions::MissingParameter->throw(
|
||||
error => "The $param parameter is mandatory" );
|
||||
}
|
||||
}
|
||||
|
||||
my $club = Koha::Clubs->find($params->{club_id});
|
||||
my @enrollments = $club->club_enrollments->as_list;
|
||||
|
|
|
|||
Loading…
Reference in New Issue