Bugzilla – Attachment 73117 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.21 KB, created by
Katrin Fischer
on 2018-03-20 23:31:45 UTC
(
hide
)
Description:
Bug 20400: Add unit tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-03-20 23:31:45 UTC
Size:
5.21 KB
patch
obsolete
>From c95f293c6a6a0b2f9fdf5de4437407937fb72542 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 > >prove t/db_dependent/Koha/Subscription/Routinglists.t >prove t/db_dependent/Koha/Patrons.t >--- > t/db_dependent/Koha/Patrons.t | 47 ++++++++++++++++- > t/db_dependent/Koha/Subscription/Routinglists.t | 69 +++++++++++++++++++++++++ > 2 files changed, 115 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 2323d21..a8f6653 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 => 25; >+use Test::More tests => 26; > use Test::Warn; > use Time::Fake; > use DateTime; >@@ -518,6 +518,51 @@ subtest '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..57f34c7 >--- /dev/null >+++ b/t/db_dependent/Koha/Subscription/Routinglists.t >@@ -0,0 +1,69 @@ >+#!/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 vcshould have received a copy of the GNU General Public License >+# al ong 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; >+$schema->storage->txn_begin; >+ >+my $biblio = Koha::Biblio->new()->store(); >+my $subscription = Koha::Subscription->new({ >+ biblionumber => $biblio->biblionumber, >+ } >+)->store; >+ >+my $builder = t::lib::TestBuilder->new; >+my $library = $builder->build({source => 'Branch' }); >+my $category = $builder->build({source => 'Category' }); >+ >+my $patron = $builder->build( { source => 'Borrower' } ); >+$patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+subtest 'new() tests' => sub { >+ plan tests => 4; >+ >+ 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