Lines 169-175
subtest 'add_update() tests' => sub {
Link Here
|
169 |
}; |
169 |
}; |
170 |
|
170 |
|
171 |
subtest 'store() tests' => sub { |
171 |
subtest 'store() tests' => sub { |
172 |
plan tests => 2; |
172 |
plan tests => 3; |
173 |
|
173 |
|
174 |
subtest 'acknowledgement notice trigger' => sub { |
174 |
subtest 'acknowledgement notice trigger' => sub { |
175 |
plan tests => 4; |
175 |
plan tests => 4; |
Lines 247-252
subtest 'store() tests' => sub {
Link Here
|
247 |
|
247 |
|
248 |
$schema->storage->txn_rollback; |
248 |
$schema->storage->txn_rollback; |
249 |
}; |
249 |
}; |
|
|
250 |
|
251 |
subtest 'assignment notice trigger' => sub { |
252 |
plan tests => 7; |
253 |
|
254 |
$schema->storage->txn_begin; |
255 |
|
256 |
my $patron = $builder->build_object( { class => "Koha::Patrons" } ); |
257 |
my $assignee = $builder->build_object( { class => "Koha::Patrons" } ); |
258 |
my $biblio = $builder->build_sample_biblio(); |
259 |
|
260 |
my $librarian = $builder->build_object( { class => "Koha::Patrons" } ); |
261 |
t::lib::Mocks::mock_userenv({ patron => $librarian }); |
262 |
|
263 |
my $new_ticket = Koha::Ticket->new( |
264 |
{ |
265 |
reporter_id => $patron->id, |
266 |
assignee_id => $assignee->id, |
267 |
title => "Testing ticket", |
268 |
body => "Testing ticket message", |
269 |
biblio_id => $biblio->id |
270 |
} |
271 |
)->store(); |
272 |
|
273 |
is( ref($new_ticket), 'Koha::Ticket', |
274 |
'Koha::Ticket->store() returned the Koha::Ticket object' ); |
275 |
my $notices = |
276 |
Koha::Notice::Messages->search( { borrowernumber => $assignee->id } ); |
277 |
is( $notices->count, 1, |
278 |
'One assignement notice queued for the ticket assignee at ticket creation' ); |
279 |
my $THE_notice = $notices->next; |
280 |
isnt( $THE_notice->status, 'pending', |
281 |
'Assignment notice is sent immediately' ); |
282 |
|
283 |
$new_ticket->set( { title => "Changed title" } )->store(); |
284 |
$notices = |
285 |
Koha::Notice::Messages->search( { borrowernumber => $assignee->id } ); |
286 |
is( $notices->count, 1, |
287 |
"Further assignment notices are not queud for subsequent stores that don't set assignee" |
288 |
); |
289 |
|
290 |
$new_ticket->set({ assignee_id => $assignee->id })->store(); |
291 |
$notices = |
292 |
Koha::Notice::Messages->search( { borrowernumber => $assignee->id } ); |
293 |
is( $notices->count, 1, |
294 |
"Further assignment notices are not queud for subsequent stores that don't change assignee" |
295 |
); |
296 |
|
297 |
my $assignee2 = $builder->build_object( { class => "Koha::Patrons" } ); |
298 |
$new_ticket->set({ assignee_id => $assignee2->id })->store(); |
299 |
$notices = |
300 |
Koha::Notice::Messages->search( { borrowernumber => $assignee2->id } ); |
301 |
is( $notices->count, 1, |
302 |
'New assignement notice queued for a change of ticket assignee' ); |
303 |
|
304 |
$new_ticket->set({ assignee_id => $librarian->id })->store(); |
305 |
$notices = |
306 |
Koha::Notice::Messages->search( { borrowernumber => $librarian->id } ); |
307 |
is( $notices->count, 0, |
308 |
'Assignment notice not queued for self-assignments' ); |
309 |
|
310 |
$schema->storage->txn_rollback; |
311 |
}; |
250 |
}; |
312 |
}; |
251 |
|
313 |
|
252 |
subtest 'strings_map() tests' => sub { |
314 |
subtest 'strings_map() tests' => sub { |
253 |
- |
|
|