Bug 26384: Fix executable flags
[koha.git] / t / db_dependent / Patron / Messages.t
blob0f099599828b234abaa480b111f0c45b5b58b34c
1 #!/usr/bin/perl
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
8 # version.
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>.
17 use Modern::Perl;
18 use Test::More tests => 1;
20 use Koha::Patrons;
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 {
30 plan tests => 2;
32 my $patron = $builder->build({ source => 'Borrower' });
33 my $message = $builder->build({
34 source => 'Message',
35 value => {
36 borrowernumber => $patron->{borrowernumber},
37 message => 'This is a message.'
39 });
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;