From 34828750b98c991baca6d744a1e9ddc6468259b5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 27 Mar 2019 06:53:44 +0000 Subject: [PATCH] Bug 22577: Test patron delete restriction --- Koha/Patron.pm | 2 +- t/db_dependent/Koha/Patrons.t | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 33056d7483..65a7e53281 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -318,7 +318,7 @@ sub delete { my ($self) = @_; unless ( $self->borrowernumber > 0 ) { - Koha::Exceptions::CannotDeleteDefault->throw( + Koha::Exceptions::Patron::FailedDelete->throw( { message => "Cannot delete system user" } ); } diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index baaa07511c..a0a46ec2eb 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -395,6 +395,8 @@ subtest "delete" => sub { my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count; is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' ); + my $system_patron = Koha::Patrons->find('-1'); + throws_ok { $system_patron->delete } 'Koha::Exceptions::Patron::FailedDelete', 'Exception raised for deleting system patron'; }; subtest 'Koha::Patrons->delete' => sub { -- 2.20.1