Bugzilla – Attachment 161636 Details for
Bug 35248
Bookings needs unit tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35248: Add unit tests for Koha::Booking relations
Bug-35248-Add-unit-tests-for-KohaBooking-relations.patch (text/plain), 4.22 KB, created by
Martin Renvoize
on 2024-01-30 13:54:53 UTC
(
hide
)
Description:
Bug 35248: Add unit tests for Koha::Booking relations
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-01-30 13:54:53 UTC
Size:
4.22 KB
patch
obsolete
>From f68639749b71a9643b8749b6dce2ae4a12e2d3c3 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 30 Jan 2024 13:53:02 +0000 >Subject: [PATCH] Bug 35248: Add unit tests for Koha::Booking relations > >This patch adds unit tests for the relations introduced in the new >Koha::Booking class. > >Test plan >1) Run t/db_dependent/Koha/Booking.t >--- > t/db_dependent/Koha/Booking.t | 97 +++++++++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > create mode 100644 t/db_dependent/Koha/Booking.t > >diff --git a/t/db_dependent/Koha/Booking.t b/t/db_dependent/Koha/Booking.t >new file mode 100644 >index 00000000000..78bb21d39db >--- /dev/null >+++ b/t/db_dependent/Koha/Booking.t >@@ -0,0 +1,97 @@ >+#!/usr/bin/perl >+ >+# Copyright 2024 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use utf8; >+ >+use Test::More tests => 1; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Relation accessor tests' => sub { >+ plan tests => 3; >+ >+ subtest 'biblio relation tests' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ my $booking = >+ $builder->build_object( { class => 'Koha::Bookings', value => { biblio_id => $biblio->biblionumber } } ); >+ >+ my $THE_biblio = $booking->biblio; >+ is( ref($THE_biblio), 'Koha::Biblio', "Koha::Booking->biblio returns a Koha::Biblio object" ); >+ is( $THE_biblio->biblionumber, $biblio->biblionumber, "Koha::Booking->biblio returns the links biblio object" ); >+ >+ $THE_biblio->delete; >+ $booking = Koha::Bookings->find( $booking->booking_id ); >+ is( $booking, undef, "The booking is deleted when the biblio it's attached to is deleted" ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'patron relation tests' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => "Koha::Patrons" } ); >+ my $booking = >+ $builder->build_object( { class => 'Koha::Bookings', value => { patron_id => $patron->borrowernumber } } ); >+ >+ my $THE_patron = $booking->patron; >+ is( ref($THE_patron), 'Koha::Patron', "Koha::Booking->patron returns a Koha::Patron object" ); >+ is( >+ $THE_patron->borrowernumber, $patron->borrowernumber, >+ "Koha::Booking->patron returns the links patron object" >+ ); >+ >+ $THE_patron->delete; >+ $booking = Koha::Bookings->find( $booking->booking_id ); >+ is( $booking, undef, "The booking is deleted when the patron it's attached to is deleted" ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'item relation tests' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $item = $builder->build_object( { class => "Koha::Items" } ); >+ my $booking = >+ $builder->build_object( { class => 'Koha::Bookings', value => { item_id => $item->itemnumber } } ); >+ >+ my $THE_item = $booking->item; >+ is( ref($THE_item), 'Koha::Item', "Koha::Booking->item returns a Koha::Item object" ); >+ is( >+ $THE_item->itemnumber, $item->itemnumber, >+ "Koha::Booking->item returns the links item object" >+ ); >+ >+ $THE_item->delete; >+ $booking = Koha::Bookings->find( $booking->booking_id ); >+ is( $booking, undef, "The booking is deleted when the item it's attached to is deleted" ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+}; >-- >2.43.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 35248
:
161061
|
161062
|
161608
|
161611
|
161620
|
161621
|
161632
|
161636
|
161651
|
161652
|
161653
|
161654
|
161655
|
161656
|
161657
|
161658
|
161659
|
161660
|
161821
|
161822
|
161823
|
161824
|
161825
|
161826
|
161827
|
161828
|
161829
|
161830
|
161831
|
161861
|
161862
|
161863
|
161864
|
161865
|
161866
|
161867
|
161868
|
161869
|
161870
|
161871
|
161890
|
161891
|
161893
|
161894
|
161895
|
161896
|
161897
|
161898
|
161899
|
161900
|
161901
|
161902
|
161903
|
161904
|
161905
|
161906
|
161907
|
161908
|
161909
|
161910
|
161911
|
161912