3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Test::More tests => 1;
21 use Koha::Patron::Messages;
22 use t::lib::TestBuilder;
24 my $schema = Koha::Database->new->schema;
25 $schema->storage->txn_begin;
27 my $builder = t::lib::TestBuilder->new;
29 subtest 'Delete a patron having messages' => sub {
32 my $patron = $builder->build({ source => 'Borrower' });
33 my $message = $builder->build({
36 borrowernumber => $patron->{borrowernumber},
37 message => 'This is a message.'
41 is(Koha::Patron::Messages->find($message->{message_id})->message, 'This is a message.', 'Got the right message');
43 my $patron_to_delete = Koha::Patrons->find( $patron->{borrowernumber} );
44 $patron_to_delete->move_to_deleted;
45 $patron_to_delete->delete;
47 is(Koha::Patron::Messages->find($message->{message_id}), undef, 'Message is deleted');
50 $schema->storage->txn_rollback;