Bugzilla – Attachment 40911 Details for
Bug 14494
Terribly slow checkout caused by DateTime->new in far future
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14494: Unit tests for CanBookBeIssued related to dateexpiry
Bug-14494-Unit-tests-for-CanBookBeIssued-related-t.patch (text/plain), 3.71 KB, created by
Jonathan Druart
on 2015-07-10 08:22:16 UTC
(
hide
)
Description:
Bug 14494: Unit tests for CanBookBeIssued related to dateexpiry
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-07-10 08:22:16 UTC
Size:
3.71 KB
patch
obsolete
>From 10dbf4b2bd4cd5674f2fca19097b832e2f6ff7c6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@koha-community.org> >Date: Thu, 9 Jul 2015 09:52:28 +0100 >Subject: [PATCH] Bug 14494: Unit tests for CanBookBeIssued related to > dateexpiry > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Moved the test on its own. Nicer than adding TestBuilder in the final part >of the test. No warnings/errors from TestBuilder, no dependency.. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Circulation_dateexpiry.t | 68 +++++++++++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > create mode 100644 t/db_dependent/Circulation_dateexpiry.t > >diff --git a/t/db_dependent/Circulation_dateexpiry.t b/t/db_dependent/Circulation_dateexpiry.t >new file mode 100644 >index 0000000..0c4d728 >--- /dev/null >+++ b/t/db_dependent/Circulation_dateexpiry.t >@@ -0,0 +1,68 @@ >+#!/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 DateTime; >+use Time::HiRes qw/gettimeofday/; >+use C4::Members; >+use Koha::DateUtils; >+use t::lib::TestBuilder; >+use Test::More tests => 1; >+ >+subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub { >+ plan tests => 4; >+ date_expiry(); >+}; >+ >+sub date_expiry { >+ my $builder = t::lib::TestBuilder->new(); >+ my $item = $builder->build( { source => 'Item' } ); >+ my $patron = $builder->build( >+ { source => 'Borrower', >+ value => { dateexpiry => '9999-12-31' } >+ } >+ ); >+ $patron->{flags} = C4::Members::patronflags( $patron ); >+ my $duration = gettimeofday(); >+ my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+ $duration = gettimeofday() - $duration; >+ cmp_ok $duration, '<', 1, "CanBookBeIssued should not be take more than 1s if the patron is expired"; >+ is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is 9999-*' ); >+ >+ $item = $builder->build( { source => 'Item' } ); >+ $patron = $builder->build( >+ { source => 'Borrower', >+ value => { dateexpiry => '0000-00-00' } >+ } >+ ); >+ $patron->{flags} = C4::Members::patronflags( $patron ); >+ ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+ is( $issuingimpossible->{EXPIRED}, 1, 'The patron should be considered as expired if dateexpiry is 0000-00-00' ); >+ >+ my $tomorrow = dt_from_string->add_duration( DateTime::Duration->new( days => 1 ) ); >+ $item = $builder->build( { source => 'Item' } ); >+ $patron = $builder->build( >+ { source => 'Borrower', >+ value => { dateexpiry => output_pref( { dt => $tomorrow, dateonly => 1, dateformat => 'sql' } ) }, >+ } >+ ); >+ $patron->{flags} = C4::Members::patronflags( $patron ); >+ ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+ is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' ); >+ >+} >-- >2.1.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 14494
:
40860
|
40873
|
40874
|
40879
|
40880
|
40881
|
40882
|
40883
|
40908
|
40909
|
40910
|
40911
|
40912
|
40932
|
40933
|
40934
|
40935