Bugzilla – Attachment 170155 Details for
Bug 36915
Send email notification when a booking is cancelled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36915: (follow-up) Add tests
Bug-36915-follow-up-Add-tests.patch (text/plain), 2.78 KB, created by
Paul Derscheid
on 2024-08-08 10:36:20 UTC
(
hide
)
Description:
Bug 36915: (follow-up) Add tests
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2024-08-08 10:36:20 UTC
Size:
2.78 KB
patch
obsolete
>From f4ea9ac35d88393b93723c9c5abb7cc65debc4c9 Mon Sep 17 00:00:00 2001 >From: Paul Derscheid <paul.derscheid@lmscloud.de> >Date: Thu, 8 Aug 2024 10:35:21 +0000 >Subject: [PATCH] Bug 36915: (follow-up) Add tests > >--- > t/db_dependent/Koha/Booking.t | 62 ++++++++++++++++++++++++++++++++++- > 1 file changed, 61 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Booking.t b/t/db_dependent/Koha/Booking.t >index 3e9b742938..97e48bc6ea 100755 >--- a/t/db_dependent/Koha/Booking.t >+++ b/t/db_dependent/Koha/Booking.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use Test::Exception; > >@@ -324,3 +324,63 @@ subtest 'store() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'delete() tests' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $biblio = $builder->build_sample_biblio; >+ my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $start_0 = dt_from_string->subtract( days => 2 )->truncate( to => 'day' ); >+ my $end_0 = $start_0->clone->add( days => 6 ); >+ my $original_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_CANCELLATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ >+ $item_1->bookable(1)->store; >+ >+ my $booking = Koha::Booking->new( >+ { >+ patron_id => $patron->borrowernumber, >+ biblio_id => $biblio->biblionumber, >+ item_id => $item_1->itemnumber, >+ pickup_library_id => $item_1->homebranch, >+ start_date => $start_0, >+ end_date => $end_0 >+ } >+ )->store; >+ >+ my $deleted = $booking->delete; >+ is( >+ ref($deleted), 'Koha::Booking', >+ 'Koha::Booking->delete should return the Koha::Booking object if the booking has been correctly deleted' >+ ); >+ is( >+ Koha::Bookings->search( { booking_id => $booking->booking_id } )->count, 0, >+ 'Koha::Booking->delete should have deleted the booking' >+ ); >+ >+ subtest 'notice trigger' => sub { >+ plan tests => 1; >+ >+ my $post_notices_count = Koha::Notice::Messages->search( >+ { >+ letter_code => 'BOOKING_CANCELLATION', >+ borrowernumber => $patron->borrowernumber, >+ } >+ )->count; >+ is( >+ $post_notices_count, >+ $original_notices_count + 1, >+ 'Koha::Booking->delete should have enqueued a BOOKING_CANCELLATION email' >+ ); >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >+ >-- >2.46.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36915
:
167010
|
167013
|
168149
|
168150
|
168155
|
170058
|
170077
|
170078
|
170079
|
170080
|
170099
|
170155
|
170203
|
170204
|
170205
|
170206
|
170207
|
170208
|
170385
|
170386
|
170387
|
170388
|
170389
|
170390
|
170391