Bugzilla – Attachment 42653 Details for
Bug 13918
Add waiting expiration date to opac list of holds for user
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13918 [QA Followup] - Unit Tests
Bug-13918-QA-Followup---Unit-Tests.patch (text/plain), 5.51 KB, created by
Kyle M Hall (khall)
on 2015-09-17 12:39:41 UTC
(
hide
)
Description:
Bug 13918 [QA Followup] - Unit Tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-09-17 12:39:41 UTC
Size:
5.51 KB
patch
obsolete
>From 24982dd345b6dbac864c04845abf79bffa0e8de7 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 24 Aug 2015 10:48:22 -0400 >Subject: [PATCH] Bug 13918 [QA Followup] - Unit Tests > >--- > Koha/Hold.pm | 14 +++++++++-- > t/db_dependent/Hold.t | 59 ++++++++++++++++++++++++++++++++++++++++++++---- > 2 files changed, 65 insertions(+), 8 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index ef45eeb..9e15ed3 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -109,13 +109,19 @@ sub is_in_transit { > > Returns true if hold is a cancelable hold > >+Holds may be canceled if they not found, or >+are found and waiting. A hold found but in >+transit cannot be canceled. >+ > =cut > > sub is_cancelable { > my ($self) = @_; > >- return ( $self->is_waiting() && !$self->is_found() ) >- || ( !$self->is_waiting() && !$self->is_in_transit() ); >+ return 1 unless $self->is_found(); >+ return 0 if $self->is_in_transit(); >+ return 1 if $self->is_waiting(); >+ return 0; > } > > =head3 is_in_transit >@@ -133,7 +139,9 @@ sub is_in_transit { > > =head3 is_at_destination > >-Returns true if hold is a in_transit hold >+Returns true if hold is waiting >+and the hold's pickup branch matches >+the hold item's holding branch > > =cut > >diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t >index 53ee364..ae8c19d 100755 >--- a/t/db_dependent/Hold.t >+++ b/t/db_dependent/Hold.t >@@ -18,10 +18,13 @@ > use Modern::Perl; > > use C4::Context; >+use C4::Biblio qw( AddBiblio ); > use Koha::Database; > use Koha::Borrowers; >+use Koha::Branches; >+use Koha::Item; > >-use Test::More tests => 16; >+use Test::More tests => 23; > > use_ok('Koha::Hold'); > >@@ -31,21 +34,48 @@ $schema->storage->txn_begin(); > my $dbh = C4::Context->dbh; > $dbh->{RaiseError} = 1; > >+my @branches = Koha::Branches->search(); > my $borrower = Koha::Borrowers->search()->next(); >+ >+my $biblio = MARC::Record->new(); >+my $title = 'Silence in the library'; >+$biblio->append_fields( >+ MARC::Field->new( '100', ' ', ' ', a => 'Moffat, Steven' ), >+ MARC::Field->new( '245', ' ', ' ', a => $title ), >+); >+my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); >+ >+my $item = Koha::Item->new( >+ { >+ biblionumber => $biblionumber, >+ biblioitemnumber => $biblioitemnumber, >+ holdingbranch => $branches[0]->branchcode(), >+ homebranch => $branches[0]->branchcode(), >+ } >+); >+$item->store(); >+ > my $hold = Koha::Hold->new( > { >+ biblionumber => $biblionumber, >+ itemnumber => $item->id(), > found => 'W', > waitingdate => '2000-01-01', > borrowernumber => $borrower->borrowernumber(), >+ branchcode => $branches[1]->branchcode(), > } > ); >+$hold->store(); >+ >+$item = $hold->item(); >+ > my $hold_borrower = $hold->borrower(); > ok( $hold_borrower, 'Got hold borrower' ); > is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' ); > > C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' ); > my $dt = $hold->waiting_expires_on(); >-is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set"); >+is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set" ); > > is( $hold->is_waiting, 1, 'The hold is waiting' ); > is( $hold->is_found, 1, 'The hold is found'); >@@ -53,22 +83,41 @@ ok( !$hold->is_in_transit, 'The hold is not in transit' ); > > C4::Context->set_preference( 'ReservesMaxPickUpDelay', '5' ); > $dt = $hold->waiting_expires_on(); >-is( $dt->ymd, "2000-01-06", "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set"); >+is( $dt->ymd, "2000-01-06", >+ "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set" ); > > $hold->found('T'); > $dt = $hold->waiting_expires_on(); >-is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to 'T' )"); >+is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to 'T' )" ); > isnt( $hold->is_waiting, 1, 'The hold is not waiting (T)' ); > is( $hold->is_found, 1, 'The hold is found'); > is( $hold->is_in_transit, 1, 'The hold is in transit' ); > > $hold->found(q{}); > $dt = $hold->waiting_expires_on(); >-is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )"); >+is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )" ); > isnt( $hold->is_waiting, 1, 'The hold is not waiting (W)' ); > is( $hold->is_found, 0, 'The hold is not found' ); > ok( !$hold->is_in_transit, 'The hold is not in transit' ); > >+# Test method is_cancelable >+$hold->found(undef); >+ok( $hold->is_cancelable(), "Unfound hold is cancelable" ); >+$hold->found('W'); >+ok( $hold->is_cancelable, "Waiting hold is cancelable" ); >+$hold->found('T'); >+ok( !$hold->is_cancelable, "In transit hold is not cancelable" ); >+ >+# Test method is_at_destination >+$hold->found(undef); >+ok( !$hold->is_at_destination(), "Unfound hold cannot be at destination" ); >+$hold->found('T'); >+ok( !$hold->is_at_destination(), "In transit hold cannot be at destination" ); >+$hold->found('W'); >+ok( !$hold->is_at_destination(), "Waiting hold where hold branchcode is not the same as the item's holdingbranch is not at destination" ); >+$item->holdingbranch( $branches[1]->branchcode() ); >+ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same as the item's holdingbranch is at destination" ); >+ > $schema->storage->txn_rollback(); > > 1; >-- >1.7.2.5
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 13918
:
37271
|
37272
|
40033
|
40035
|
41862
|
41863
|
41864
|
41865
|
41945
|
41946
|
41947
|
41948
|
42652
|
42653
|
42654
|
42655
|
42656
|
42745
|
42746
|
42747
|
42748
|
42749
|
42779
|
42780
|
42781
|
42782
|
42783
|
43429
|
43430
|
43431
|
43432
|
43433
|
43438
|
43502
|
43503
|
43504
|
43505
|
43506
|
43507
|
46130
|
46131
|
46132
|
46133
|
46134
|
46135