Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
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. |
9 |
# |
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. |
13 |
# |
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>. |
16 |
# |
17 |
use Modern::Perl; |
18 |
use Test::More tests => 1; |
19 |
|
20 |
use Koha::Patrons; |
21 |
use Koha::Patron::Messages; |
22 |
use t::lib::TestBuilder; |
23 |
|
24 |
my $schema = Koha::Database->new->schema; |
25 |
$schema->storage->txn_begin; |
26 |
|
27 |
my $builder = t::lib::TestBuilder->new; |
28 |
|
29 |
subtest 'Delete a patron having messages' => sub { |
30 |
plan tests => 2; |
31 |
|
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.' |
38 |
} |
39 |
}); |
40 |
|
41 |
is(Koha::Patron::Messages->find($message->{message_id})->message, 'This is a message.', 'Got the right message'); |
42 |
|
43 |
my $patron_to_delete = Koha::Patrons->find( $patron->{borrowernumber} ); |
44 |
$patron_to_delete->move_to_deleted; |
45 |
$patron_to_delete->delete; |
46 |
|
47 |
is(Koha::Patron::Messages->find($message->{message_id}), undef, 'Message is deleted'); |
48 |
}; |
49 |
|
50 |
$schema->storage->txn_rollback; |