3 # Copyright 2017 Koha-Suomi Oy
5 # This file is part of Koha
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 2;
26 my $schema = Koha::Database->new->schema;
28 subtest 'Test class imports' => sub {
31 use_ok('Koha::Patron::MessagePreference::Attribute');
32 use_ok('Koha::Patron::MessagePreference::Attributes');
35 subtest 'Test Koha::Patron::MessagePreference::Attributes' => sub {
38 $schema->storage->txn_begin;
40 Koha::Patron::MessagePreference::Attribute->new({
41 message_name => 'Test_Attribute'
43 Koha::Patron::MessagePreference::Attribute->new({
44 message_name => 'Test_Attribute2',
48 my $attribute = Koha::Patron::MessagePreference::Attributes->find({
49 message_name => 'Test_Attribute' });
50 my $attribute2 = Koha::Patron::MessagePreference::Attributes->find({
51 message_name => 'Test_Attribute2' });
53 is($attribute->message_name, 'Test_Attribute',
54 'Added a new messaging attribute.');
55 is($attribute->takes_days, 0,
56 'For that messaging attribute, takes_days is disabled by default.');
57 is($attribute2->message_name, 'Test_Attribute2',
58 'Added another messaging attribute.');
59 is($attribute2->takes_days, 1,
60 'takes_days is enabled for that message attribute (as expected).');
64 is(Koha::Patron::MessagePreference::Attributes->find({
65 message_name => 'Test_Attribute' }), undef,
66 'Deleted the first message attribute.');
67 is(Koha::Patron::MessagePreference::Attributes->find({
68 message_name => 'Test_Attribute2' }), undef,
69 'Deleted the second message attribute.');
71 $schema->storage->txn_rollback;