Bugzilla – Attachment 74634 Details for
Bug 20400
Add routing list tab to the patron account in OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20400: Add unit tests
Bug-20400-Add-unit-tests.patch (text/plain), 5.36 KB, created by
Nick Clemens (kidclamp)
on 2018-04-20 12:58:31 UTC
(
hide
)
Description:
Bug 20400: Add unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-04-20 12:58:31 UTC
Size:
5.36 KB
patch
obsolete
>From f56dcbc5b98b97eaeb9941737cba6eae5cd1cda1 Mon Sep 17 00:00:00 2001 >From: Katrin Fischer <katrin.fischer.83@web.de> >Date: Sat, 17 Mar 2018 21:25:35 +0100 >Subject: [PATCH] Bug 20400: Add unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >prove t/db_dependent/Koha/Subscription/Routinglists.t >prove t/db_dependent/Koha/Patrons.t > >Signed-off-by: Dilan Johnpullé <dilan@calyx.net.au> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Patrons.t | 45 ++++++++++++++++- > t/db_dependent/Koha/Subscription/Routinglists.t | 67 +++++++++++++++++++++++++ > 2 files changed, 111 insertions(+), 1 deletion(-) > create mode 100644 t/db_dependent/Koha/Subscription/Routinglists.t > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 0b6e122..ea57389 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 29; >+use Test::More tests => 30; > use Test::Warn; > use Time::Fake; > use DateTime; >@@ -529,6 +529,49 @@ subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { > $module->unmock('userenv'); > }; > >+subtest 'get_routinglists' => sub { >+ plan tests => 5; >+ >+ my $biblio = Koha::Biblio->new()->store(); >+ my $subscription = Koha::Subscription->new({ >+ biblionumber => $biblio->biblionumber, >+ } >+ )->store; >+ >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+ is( $patron->get_routinglists, 0, 'Retrieves correct number of routing lists: 0' ); >+ >+ my $routinglist_count = Koha::Subscription::Routinglists->count; >+ my $routinglist = Koha::Subscription::Routinglist->new({ >+ borrowernumber => $patron->borrowernumber, >+ ranking => 5, >+ subscriptionid => $subscription->subscriptionid >+ })->store; >+ >+ is ($patron->get_routinglists, 1, "Retrieves correct number of routing lists: 1"); >+ >+ my @routinglists = $patron->get_routinglists; >+ is ($routinglists[0]->ranking, 5, "Retrieves ranking: 5"); >+ is( ref($routinglists[0]), 'Koha::Subscription::Routinglist', 'get_routinglists returns Koha::Subscription::Routinglist objects' ); >+ >+ my $subscription2 = Koha::Subscription->new({ >+ biblionumber => $biblio->biblionumber, >+ } >+ )->store; >+ my $routinglist2 = Koha::Subscription::Routinglist->new({ >+ borrowernumber => $patron->borrowernumber, >+ ranking => 1, >+ subscriptionid => $subscription2->subscriptionid >+ })->store; >+ >+ is ($patron->get_routinglists, 2, "Retrieves correct number of routing lists: 2"); >+ >+ $patron->delete; # Clean up for later tests >+ >+}; >+ > subtest 'get_age' => sub { > plan tests => 7; > >diff --git a/t/db_dependent/Koha/Subscription/Routinglists.t b/t/db_dependent/Koha/Subscription/Routinglists.t >new file mode 100644 >index 0000000..1eff86c >--- /dev/null >+++ b/t/db_dependent/Koha/Subscription/Routinglists.t >@@ -0,0 +1,67 @@ >+#!/usr/bin/perl >+ >+# 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 >+# WIT HOUT 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 => 1; >+use t::lib::TestBuilder; >+ >+use C4::Biblio; >+ >+use Koha::Database; >+use Koha::Patrons; >+use Koha::Subscriptions; >+use Koha::Subscription::Routinglists; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'new() tests' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = Koha::Biblio->new()->store(); >+ my $subscription = Koha::Subscription->new({ >+ biblionumber => $biblio->biblionumber, >+ } >+ )->store; >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->id } }); >+ >+ my $routinglist_count = Koha::Subscription::Routinglists->count; >+ my $routinglist = Koha::Subscription::Routinglist->new({ >+ borrowernumber => $patron->borrowernumber, >+ ranking => 1, >+ subscriptionid => $subscription->subscriptionid >+ })->store; >+ >+ is( Koha::Subscription::Routinglists->search->count, $routinglist_count +1, 'One routing list added' ); >+ >+ my $retrieved_routinglist = Koha::Subscription::Routinglists->find( $routinglist->routingid ); >+ is ( $retrieved_routinglist->routingid, $routinglist->routingid, "Find a routing list by id returns the correct routing list"); >+ >+ $routinglist->ranking(4)->update; >+ is ( $routinglist->ranking, 4, "Routing list ranking has been updated"); >+ >+ $routinglist->delete; >+ is ( Koha::Subscription::Routinglists->search->count, $routinglist_count, 'One subscription list deleted' ); >+ >+}; >+ >+$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 20400
:
72973
|
72974
|
73115
|
73116
|
73117
|
73118
|
73121
|
73122
|
73123
|
73124
|
74291
|
74292
|
74293
|
74294
|
74295
|
74296
|
74297
|
74298
|
74299
|
74300
|
74402
|
74588
|
74589
|
74590
|
74592
|
74593
|
74632
|
74633
| 74634 |
74635
|
74636
|
74637
|
74662
|
74664
|
74666