Bugzilla – Attachment 107130 Details for
Bug 25951
Koha::Objects using the DBIx::Class relationships in Koha::Hold and Koha::Item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25951: Add tests for Holds and Item related Objects
Bug-25951-Add-tests-for-Holds-and-Item-related-Obj.patch (text/plain), 3.77 KB, created by
Nicolas Legrand
on 2020-07-21 09:12:31 UTC
(
hide
)
Description:
Bug 25951: Add tests for Holds and Item related Objects
Filename:
MIME Type:
Creator:
Nicolas Legrand
Created:
2020-07-21 09:12:31 UTC
Size:
3.77 KB
patch
obsolete
>From ac0ad9ddfd21fd0ed65e6f49429002274455a994 Mon Sep 17 00:00:00 2001 >From: Nicolas Legrand <nicolas.legrand@bulac.fr> >Date: Tue, 21 Jul 2020 11:06:27 +0200 >Subject: [PATCH] Bug 25951: Add tests for Holds and Item related Objects > >Test plan: > >1. apply patch >2. `prove t/db_dependent/Koha/Holds.t` and >`t/db_dependent/Koha/Item/RelatedObjects.t` >3. all should be OK >--- > t/db_dependent/Koha/Holds.t | 15 +++++++-- > t/db_dependent/Koha/Item/RelatedObjects.t | 55 +++++++++++++++++++++++++++++++ > 2 files changed, 68 insertions(+), 2 deletions(-) > create mode 100644 t/db_dependent/Koha/Item/RelatedObjects.t > >diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t >index 055dd18..6a8a4b4 100644 >--- a/t/db_dependent/Koha/Holds.t >+++ b/t/db_dependent/Koha/Holds.t >@@ -35,7 +35,7 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > subtest 'DB constraints' => sub { >- plan tests => 1; >+ plan tests => 2; > > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > my $item = $builder->build_sample_item; >@@ -55,7 +55,18 @@ subtest 'DB constraints' => sub { > eval { $hold->priority(undef)->store } > } > qr{.*DBD::mysql::st execute failed: Column 'priority' cannot be null.*}, >- 'DBD should have raised an error about priority that cannot be null'; >+ 'DBD should have raised an error about priority that cannot be null'; >+ >+ subtest 'Related objects' => sub { >+ plan tests => 3; >+ my $item = $hold->item; >+ is(ref($item), 'Koha::Item', 'Returns a Koha::Item resultset' ); >+ my $patron = $hold->borrower; >+ is(ref($patron), 'Koha::Patron', 'Returns a Koha::Patron resultset' ); >+ my $library = $hold->branch; >+ is(ref($library), 'Koha::Library', 'Returns a Koha::Branch resultset' ); >+ }; >+ > }; > > subtest 'cancel' => sub { >diff --git a/t/db_dependent/Koha/Item/RelatedObjects.t b/t/db_dependent/Koha/Item/RelatedObjects.t >new file mode 100644 >index 0000000..fff4119 >--- /dev/null >+++ b/t/db_dependent/Koha/Item/RelatedObjects.t >@@ -0,0 +1,55 @@ >+#!/usr/bin/perl >+ >+# Copyright 2020 BULAC >+# >+# 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 Test::More tests => 2; >+ >+use C4::Biblio; >+use C4::Circulation; >+ >+use Koha::Items; >+use Koha::Database; >+use Koha::Old::Items; >+ >+use List::MoreUtils qw(all); >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+ >+$schema->storage->txn_begin; >+my $library = $builder->build( { source => 'Branch' } ); >+my $nb_of_items = Koha::Items->search->count; >+my $biblio = $builder->build_sample_biblio(); >+my $new_item = $builder->build_sample_item({ >+ biblionumber => $biblio->biblionumber, >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ }); >+my $home_branch = $new_item->home_branch; >+is(ref($home_branch), 'Koha::Library', 'Returns a Koha::Library resultset' ); >+my $holding_branch = $new_item->holding_branch; >+is(ref($holding_branch), 'Koha::Library', 'Returns a Koha::Library resultset' ); >+$schema->storage->txn_rollback; >+ >+ >-- >2.1.4
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 25951
:
106649
|
107129
| 107130 |
107131