View | Details | Raw Unified | Return to bug 17499
Collapse All | Expand All

(-)a/Koha/Patron/Message/Attribute.pm (+50 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Attribute;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.a
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Patron::Message::Attribute - Koha Patron Message Attribute object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'MessageAttribute';
42
}
43
44
=head1 AUTHOR
45
46
Lari Taskula <lari.taskula@jns.fi>
47
48
=cut
49
50
1;
(-)a/Koha/Patron/Message/Attributes.pm (+55 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Attributes;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
use Koha::Patron::Message::Attribute;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Patron::Message::Attributes - Koha Patron Message Attributes object class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=cut
36
37
=head3 type
38
39
=cut
40
41
sub _type {
42
    return 'MessageAttribute';
43
}
44
45
sub object_class {
46
    return 'Koha::Patron::Message::Attribute';
47
}
48
49
=head1 AUTHOR
50
51
Lari Taskula <lari.taskula@jns.fi>
52
53
=cut
54
55
1;
(-)a/Koha/Patron/Message/Preference.pm (+50 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Preference;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.a
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Patron::Message::Preference - Koha Patron Message Preference object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'BorrowerMessagePreference';
42
}
43
44
=head1 AUTHOR
45
46
Lari Taskula <lari.taskula@jns.fi>
47
48
=cut
49
50
1;
(-)a/Koha/Patron/Message/Preferences.pm (+55 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Preferences;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
use Koha::Patron::Message::Preference;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Patron::Message::Preferences - Koha Patron Message Preferences object class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=cut
36
37
=head3 type
38
39
=cut
40
41
sub _type {
42
    return 'BorrowerMessagePreference';
43
}
44
45
sub object_class {
46
    return 'Koha::Patron::Message::Preference';
47
}
48
49
=head1 AUTHOR
50
51
Lari Taskula <lari.taskula@jns.fi>
52
53
=cut
54
55
1;
(-)a/Koha/Patron/Message/Transport.pm (+50 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Transport;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.a
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Patron::Message::Transport - Koha Patron Message Transport object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'MessageTransport';
42
}
43
44
=head1 AUTHOR
45
46
Lari Taskula <lari.taskula@jns.fi>
47
48
=cut
49
50
1;
(-)a/Koha/Patron/Message/Transport/Preference.pm (+51 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Transport::Preference;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.a
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Patron::Message::Transport::Preference - Koha Patron Message Transport
29
Preference object class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=cut
36
37
=head3 type
38
39
=cut
40
41
sub _type {
42
    return 'BorrowerMessageTransportPreference';
43
}
44
45
=head1 AUTHOR
46
47
Lari Taskula <lari.taskula@jns.fi>
48
49
=cut
50
51
1;
(-)a/Koha/Patron/Message/Transport/Preferences.pm (+56 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Transport::Preferences;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
use Koha::Patron::Message::Transport::Preference;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Patron::Message::Transport::Preferences - Koha Patron Message Transport
30
Preferences object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'BorrowerMessageTransportPreference';
44
}
45
46
sub object_class {
47
    return 'Koha::Patron::Message::Transport::Preference';
48
}
49
50
=head1 AUTHOR
51
52
Lari Taskula <lari.taskula@jns.fi>
53
54
=cut
55
56
1;
(-)a/Koha/Patron/Message/Transport/Type.pm (+51 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Transport::Type;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.a
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Patron::Message::Transport::Type - Koha Patron Message Transport Type
29
object class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=cut
36
37
=head3 type
38
39
=cut
40
41
sub _type {
42
    return 'MessageTransportType';
43
}
44
45
=head1 AUTHOR
46
47
Lari Taskula <lari.taskula@jns.fi>
48
49
=cut
50
51
1;
(-)a/Koha/Patron/Message/Transport/Types.pm (+56 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Transport::Types;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
use Koha::Patron::Message::Transport::Type;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Patron::Message::Transport::Types - Koha Patron Message Transport Types
30
object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'MessageTransportType';
44
}
45
46
sub object_class {
47
    return 'Koha::Patron::Message::Transport::Type';
48
}
49
50
=head1 AUTHOR
51
52
Lari Taskula <lari.taskula@jns.fi>
53
54
=cut
55
56
1;
(-)a/Koha/Patron/Message/Transports.pm (+55 lines)
Line 0 Link Here
1
package Koha::Patron::Message::Transports;
2
3
# Copyright Koha-Suomi Oy 2016
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Koha::Database;
23
use Koha::Patron::Message::Transport;
24
25
use base qw(Koha::Objects);
26
27
=head1 NAME
28
29
Koha::Patron::Message::Transports - Koha Patron Message Transports object class
30
31
=head1 API
32
33
=head2 Class Methods
34
35
=cut
36
37
=head3 type
38
39
=cut
40
41
sub _type {
42
    return 'MessageTransport';
43
}
44
45
sub object_class {
46
    return 'Koha::Patron::Message::Transport';
47
}
48
49
=head1 AUTHOR
50
51
Lari Taskula <lari.taskula@jns.fi>
52
53
=cut
54
55
1;
(-)a/t/db_dependent/Koha/Patron/Message/Preferences.t (-1 / +125 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2016 Koha-Suomi Oy
4
#
5
# This file is part of Koha
6
#
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.
11
#
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.
16
#
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>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 15;
23
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
26
27
use Koha::Patrons;
28
29
use_ok("Koha::Patron::Message::Attribute");
30
use_ok("Koha::Patron::Message::Attributes");
31
use_ok("Koha::Patron::Message::Preference");
32
use_ok("Koha::Patron::Message::Preferences");
33
use_ok("Koha::Patron::Message::Transport");
34
use_ok("Koha::Patron::Message::Transport::Preference");
35
use_ok("Koha::Patron::Message::Transport::Preferences");
36
use_ok("Koha::Patron::Message::Transport::Type");
37
use_ok("Koha::Patron::Message::Transport::Types");
38
use_ok("Koha::Patron::Message::Transports");
39
40
my $schema = Koha::Database->new->schema;
41
$schema->storage->txn_begin;
42
43
my $builder        = t::lib::TestBuilder->new;
44
my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode();
45
my $branchcode = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode();
46
47
my $patron = $builder->build({ source => 'Borrower',
48
    value => {
49
        branchcode   => $branchcode,
50
        categorycode => $categorycode,
51
    }
52
});
53
54
my $attribute;
55
my $preference;
56
my $transport_preference;
57
my $transport_type;
58
59
subtest 'Add a test messaging transport type' => sub {
60
    plan tests => 2;
61
62
    ok($transport_type = Koha::Patron::Message::Transport::Type->new({
63
        message_transport_type => "test"
64
    })->store, "Added a new messaging transport type.");
65
    is(Koha::Patron::Message::Transport::Types->find({
66
        message_transport_type => "test" })->message_transport_type,
67
       "test" , "Found test messaging transport type from database.");
68
};
69
70
subtest 'Add a test messaging attribute' => sub {
71
    plan tests => 2;
72
73
    ok($attribute = Koha::Patron::Message::Attribute->new({
74
        message_name => "Test_Attribute"
75
    })->store, "Added a new messaging attribute.");
76
    is(Koha::Patron::Message::Attributes->find({
77
        message_name => "Test_Attribute"})->message_name,
78
       "Test_Attribute", "Found test attribute from database.");
79
};
80
81
subtest 'Add a test messaging transport' => sub {
82
    plan tests => 2;
83
84
    ok(Koha::Patron::Message::Transport->new({
85
        message_attribute_id => $attribute->message_attribute_id,
86
        message_transport_type => $transport_type->message_transport_type,
87
        is_digest => 0,
88
        letter_module => "circulation",
89
        letter_code => "CHECKIN",
90
    })->store, "Added a new messaging transport type.");
91
    is(Koha::Patron::Message::Transports->find({
92
        message_transport_type => "test" })->message_attribute_id,
93
       $attribute->message_attribute_id , "Found test messaging transport from database.");
94
};
95
96
subtest 'Add a messaging preference to patron' => sub {
97
    plan tests => 2;
98
99
    ok($preference = Koha::Patron::Message::Preference->new({
100
        borrowernumber => $patron->{'borrowernumber'},
101
        message_attribute_id => $attribute->message_attribute_id,
102
        wants_digest => 0,
103
        days_in_advance => 1,
104
    })->store, "Added a new messaging preference for patron.");
105
    is(Koha::Patron::Message::Preferences->find({
106
        borrowernumber => $patron->{'borrowernumber'} })->message_attribute_id,
107
       $preference->message_attribute_id, "Found test messaging preference from database.");
108
};
109
110
subtest 'Add a messaging transport preference to patron' => sub {
111
    plan tests => 2;
112
113
    ok($transport_preference = Koha::Patron::Message::Transport::Preference->new({
114
        borrower_message_preference_id => $preference->borrower_message_preference_id,
115
        message_transport_type => $transport_type->message_transport_type,
116
    })->store, "Added a new messaging transport preference for patron.");
117
    is(Koha::Patron::Message::Transport::Preferences->find({
118
        message_transport_type => $transport_type->message_transport_type
119
        })->borrower_message_preference_id, $transport_preference->borrower_message_preference_id,
120
       "Found test messaging transport preference from database.");
121
};
122
123
$schema->storage->txn_rollback;
124
125
1;

Return to bug 17499