Bugzilla – Attachment 47619 Details for
Bug 9805
Lost items are un-lost if returned, but not if renewed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9805 - Unit Tests
Bug-9805---Unit-Tests.patch (text/plain), 4.28 KB, created by
Kyle M Hall (khall)
on 2016-02-03 17:59:52 UTC
(
hide
)
Description:
Bug 9805 - Unit Tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-02-03 17:59:52 UTC
Size:
4.28 KB
patch
obsolete
>From 81bde0c60c33648472869d7c736be3ed3065e489 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 3 Feb 2016 17:10:37 +0000 >Subject: [PATCH] Bug 9805 - Unit Tests > >--- > t/db_dependent/Circulation/Renewal.t | 142 +++++++++++++++++++++++++++++++++++ > 1 file changed, 142 insertions(+) > create mode 100755 t/db_dependent/Circulation/Renewal.t > >diff --git a/t/db_dependent/Circulation/Renewal.t b/t/db_dependent/Circulation/Renewal.t >new file mode 100755 >index 0000000..5dc10e6 >--- /dev/null >+++ b/t/db_dependent/Circulation/Renewal.t >@@ -0,0 +1,142 @@ >+#!/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 >+# 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 C4::Biblio; >+use C4::Items; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+use Test::More tests => 7; >+ >+BEGIN { >+ use_ok('C4::Circulation'); >+} >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+my $builder = t::lib::TestBuilder->new; >+my $dbh = C4::Context->dbh; >+ >+# Start transaction >+$dbh->{RaiseError} = 1; >+ >+# Start with a clean slate >+$dbh->do('DELETE FROM issues'); >+ >+my $library = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $borrower = $builder->build( >+ { >+ source => 'Borrower', >+ } >+); >+ >+# Now, set a userenv >+C4::Context->_new_userenv('xxx'); >+C4::Context->set_userenv( >+ 0, 0, 0, 'firstname', 'surname', >+ $library->{branchcode}, >+ 'Midway Public Library', >+ '', '', '' >+); >+is( C4::Context->userenv->{branch}, $library->{branchcode}, 'userenv set' ); >+ >+my $biblio = MARC::Record->new(); >+my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); >+ >+my $barcode = '1234'; >+my ( undef, undef, $itemnumber ) = AddItem( >+ { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ barcode => $barcode, >+ }, >+ $biblionumber >+); >+ >+$dbh->do('DELETE FROM issuingrules'); >+$schema->resultset('Issuingrule')->create( >+ { >+ categorycode => '*', >+ branchcode => '*', >+ itemtype => '*', >+ maxissueqty => 20, >+ issuelength => 14, >+ lengthunit => 'days', >+ renewalsallowed => 99, >+ renewalperiod => 7, >+ } >+); >+ >+my $issue = AddIssue( $borrower, $barcode ); >+ >+my $item = Koha::Items->find($itemnumber); >+$item->itemlost(1)->store(); >+ >+$dbh->do('DELETE FROM default_branch_circ_rules'); >+ >+$dbh->do('DELETE FROM default_circ_rules'); >+$schema->resultset('DefaultCircRule')->create( >+ { >+ renew_lost_allowed => 0, >+ renew_lost_found => 0, >+ } >+); >+ >+my ( $ok, $error ); >+( $ok, $error ) = CanBookBeRenewed( $borrower->{borrowernumber}, $itemnumber ); >+ >+is( $ok, 0, "Lost item cannot be renewed" ); >+is( $error, 'item_lost', "Lost item cannot be renewed, error is item_lost" ); >+ >+$dbh->do('DELETE FROM default_circ_rules'); >+$schema->resultset('DefaultCircRule')->create( >+ { >+ renew_lost_allowed => 1, >+ renew_lost_found => 0, >+ } >+); >+( $ok, $error ) = CanBookBeRenewed( $borrower->{borrowernumber}, $itemnumber ); >+ >+is( $ok, 1, "Lost item can be renewed" ); >+ >+AddRenewal( $borrower->{borrowernumber}, $itemnumber, $library->{branchcode} ); >+$item = Koha::Items->find($itemnumber); >+is( $item->itemlost, 1, >+ "Item still lost after renewal with renew_lost_found = 0" ); >+ >+$dbh->do('DELETE FROM default_circ_rules'); >+$schema->resultset('DefaultCircRule')->create( >+ { >+ renew_lost_allowed => 1, >+ renew_lost_found => 1, >+ } >+); >+ >+AddRenewal( $borrower->{borrowernumber}, $itemnumber, $library->{branchcode} ); >+$item = Koha::Items->find($itemnumber); >+is( $item->itemlost, 0, >+ "Item no longer lost after renewal with renew_lost_found = 1" ); >+ >+1; >-- >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 9805
:
16089
|
16090
|
16302
|
29214
|
37008
|
38430
|
38432
|
38433
|
45411
|
45412
|
45413
|
46539
|
46540
|
46541
|
47616
|
47617
|
47618
|
47619
|
48779
|
48780
|
48781
|
49091
|
49092
|
49093
|
49165
|
162473