|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 3; |
20 |
use Test::More tests => 4; |
| 21 |
use Test::Exception; |
21 |
use Test::Exception; |
| 22 |
|
22 |
|
| 23 |
use Koha::City; |
23 |
use Koha::City; |
|
Lines 193-198
subtest 'workflow' => sub {
Link Here
|
| 193 |
$cp->mark_as_delivered; |
193 |
$cp->mark_as_delivered; |
| 194 |
is( $cp->status, 'delivered' ); |
194 |
is( $cp->status, 'delivered' ); |
| 195 |
is( $pickups->filter_by_delivered->count, 1 ); |
195 |
is( $pickups->filter_by_delivered->count, 1 ); |
|
|
196 |
|
| 197 |
$cp->delete; |
| 196 |
}; |
198 |
}; |
| 197 |
|
199 |
|
| 198 |
subtest 'mark_as_delivered' => sub { |
200 |
subtest 'mark_as_delivered' => sub { |
|
Lines 230-236
subtest 'mark_as_delivered' => sub {
Link Here
|
| 230 |
|
232 |
|
| 231 |
is( $hold->get_from_storage, undef, 'Hold has been filled' ); |
233 |
is( $hold->get_from_storage, undef, 'Hold has been filled' ); |
| 232 |
my $checkout = Koha::Checkouts->find({ itemnumber => $item->itemnumber }); |
234 |
my $checkout = Koha::Checkouts->find({ itemnumber => $item->itemnumber }); |
| 233 |
is( $checkout->borrowernumber, $patron->borrowernumber, 'Item has correctly been checked out' ) |
235 |
is( $checkout->borrowernumber, $patron->borrowernumber, 'Item has correctly been checked out' ); |
|
|
236 |
|
| 237 |
$cp->delete; |
| 238 |
}; |
| 239 |
|
| 240 |
subtest 'notify_new_pickup' => sub { |
| 241 |
plan tests => 2; |
| 242 |
|
| 243 |
my $item = |
| 244 |
$builder->build_sample_item( { library => $library->branchcode } ); |
| 245 |
my $reserve_id = C4::Reserves::AddReserve( |
| 246 |
{ |
| 247 |
branchcode => $library->branchcode, |
| 248 |
borrowernumber => $patron->borrowernumber, |
| 249 |
biblionumber => $item->biblionumber, |
| 250 |
priority => 1, |
| 251 |
itemnumber => $item->itemnumber, |
| 252 |
} |
| 253 |
); |
| 254 |
my $hold = Koha::Holds->find($reserve_id); |
| 255 |
$hold->set_waiting; |
| 256 |
|
| 257 |
my $next_monday = |
| 258 |
$today->clone->add( days => ( 1 - $today->day_of_week ) % 7 ); |
| 259 |
my $schedule_dt = |
| 260 |
$next_monday->set_hour(15)->set_minute(00)->set_second(00); |
| 261 |
my $cp = Koha::CurbsidePickup->new( |
| 262 |
{ |
| 263 |
branchcode => $library->branchcode, |
| 264 |
borrowernumber => $patron->borrowernumber, |
| 265 |
scheduled_pickup_datetime => $schedule_dt, |
| 266 |
notes => 'just a note' |
| 267 |
} |
| 268 |
)->store; |
| 269 |
|
| 270 |
$patron->set( { email => 'test@example.org' } )->store; |
| 271 |
my $dbh = C4::Context->dbh; |
| 272 |
$dbh->do( q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ?)|, |
| 273 |
undef, $patron->borrowernumber, 4 |
| 274 |
); |
| 275 |
my $borrower_message_preference_id = |
| 276 |
$dbh->last_insert_id( undef, undef, "borrower_message_preferences", undef ); |
| 277 |
$dbh->do( |
| 278 |
q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, |
| 279 |
undef, $borrower_message_preference_id, 'email' |
| 280 |
); |
| 281 |
|
| 282 |
$cp->notify_new_pickup; |
| 283 |
|
| 284 |
my $messages = C4::Letters::GetQueuedMessages( |
| 285 |
{ borrowernumber => $patron->borrowernumber } ); |
| 286 |
is( |
| 287 |
$messages->[0]->{subject}, |
| 288 |
sprintf ("You have schedule a curbside pickup for %s.", $library->branchname), |
| 289 |
"Notice correctly generated" |
| 290 |
); |
| 291 |
my $biblio_title = $item->biblio->title; |
| 292 |
like( $messages->[0]->{content}, |
| 293 |
qr{$biblio_title}, "Content contains the list of waiting holds" ); |
| 234 |
}; |
294 |
}; |
| 235 |
|
295 |
|
| 236 |
$schema->storage->txn_rollback; |
296 |
$schema->storage->txn_rollback; |
| 237 |
- |
|
|