Lines 49-55
subtest 'Test Koha::Patron::Message::Preferences' => sub {
Link Here
|
49 |
my $attribute = build_a_test_attribute(); |
49 |
my $attribute = build_a_test_attribute(); |
50 |
|
50 |
|
51 |
subtest 'Test for a patron' => sub { |
51 |
subtest 'Test for a patron' => sub { |
52 |
plan tests => 2; |
52 |
plan tests => 3; |
53 |
|
53 |
|
54 |
my $patron = build_a_test_patron(); |
54 |
my $patron = build_a_test_patron(); |
55 |
Koha::Patron::Message::Preference->new({ |
55 |
Koha::Patron::Message::Preference->new({ |
Lines 66-71
subtest 'Test Koha::Patron::Message::Preferences' => sub {
Link Here
|
66 |
ok($preference->borrower_message_preference_id > 0, |
66 |
ok($preference->borrower_message_preference_id > 0, |
67 |
'Added a new messaging preference for patron.'); |
67 |
'Added a new messaging preference for patron.'); |
68 |
|
68 |
|
|
|
69 |
subtest 'Test set not throwing an exception on duplicate object' => sub { |
70 |
plan tests => 1; |
71 |
|
72 |
Koha::Patron::Message::Attributes->find({ |
73 |
message_attribute_id => $attribute->message_attribute_id |
74 |
})->set({ takes_days => 1 })->store; |
75 |
$preference->set({ days_in_advance => 1 })->store; |
76 |
is(ref($preference), 'Koha::Patron::Message::Preference', |
77 |
'Updating the preference does not cause duplicate object exception'); |
78 |
}; |
79 |
|
69 |
$preference->delete; |
80 |
$preference->delete; |
70 |
is(Koha::Patron::Message::Preferences->search({ |
81 |
is(Koha::Patron::Message::Preferences->search({ |
71 |
borrowernumber => $patron->borrowernumber, |
82 |
borrowernumber => $patron->borrowernumber, |
Lines 100-106
subtest 'Test Koha::Patron::Message::Preferences' => sub {
Link Here
|
100 |
}; |
111 |
}; |
101 |
|
112 |
|
102 |
subtest 'Test adding a new preference with invalid parameters' => sub { |
113 |
subtest 'Test adding a new preference with invalid parameters' => sub { |
103 |
plan tests => 3; |
114 |
plan tests => 4; |
104 |
|
115 |
|
105 |
subtest 'Missing parameters' => sub { |
116 |
subtest 'Missing parameters' => sub { |
106 |
plan tests => 1; |
117 |
plan tests => 1; |
Lines 178-183
subtest 'Test adding a new preference with invalid parameters' => sub {
Link Here
|
178 |
|
189 |
|
179 |
$schema->storage->txn_rollback; |
190 |
$schema->storage->txn_rollback; |
180 |
}; |
191 |
}; |
|
|
192 |
|
193 |
subtest 'Duplicate object' => sub { |
194 |
plan tests => 2; |
195 |
|
196 |
$schema->storage->txn_begin; |
197 |
|
198 |
my $attribute = build_a_test_attribute(); |
199 |
my $patron = build_a_test_patron(); |
200 |
my $preference = Koha::Patron::Message::Preference->new({ |
201 |
borrowernumber => $patron->borrowernumber, |
202 |
message_attribute_id => $attribute->message_attribute_id, |
203 |
wants_digest => 0, |
204 |
days_in_advance => undef, |
205 |
})->store; |
206 |
ok($preference->borrower_message_preference_id, |
207 |
'Added a new messaging preference for patron.'); |
208 |
eval { Koha::Patron::Message::Preference->new({ |
209 |
borrowernumber => $patron->borrowernumber, |
210 |
message_attribute_id => $attribute->message_attribute_id, |
211 |
wants_digest => 0, |
212 |
days_in_advance => undef, |
213 |
})->store }; |
214 |
is(ref $@, 'Koha::Exceptions::DuplicateObject', |
215 |
'Adding a duplicate preference' |
216 |
.' => Koha::Exceptions::DuplicateObject'); |
217 |
|
218 |
$schema->storage->txn_rollback; |
219 |
}; |
181 |
}; |
220 |
}; |
182 |
|
221 |
|
183 |
sub build_a_test_attribute { |
222 |
sub build_a_test_attribute { |
184 |
- |
|
|