Bugzilla – Attachment 117583 Details for
Bug 25767
Add Koha::Item::Transfer->receive method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25767: Add Koha::Item::Transfer->receive method
Bug-25767-Add-KohaItemTransfer-receive-method.patch (text/plain), 4.01 KB, created by
Jonathan Druart
on 2021-03-03 14:29:59 UTC
(
hide
)
Description:
Bug 25767: Add Koha::Item::Transfer->receive method
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-03 14:29:59 UTC
Size:
4.01 KB
patch
obsolete
>From acf90838bb9660e15a7808a70f0379cbbe63df80 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 20 Jan 2020 15:51:39 +0000 >Subject: [PATCH] Bug 25767: Add Koha::Item::Transfer->receive method >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Was Bug 25767: Add Koha::Item::Transfer->receipt method > >Signed-off-by: Kathleen Milne <kathleen.milne@cne-siar.gov.uk> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> > >Bug 25767: Add unit tests for Koha::Item::Transfer->receipt > >Signed-off-by: Kathleen Milne <kathleen.milne@cne-siar.gov.uk> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> > >Bug 25767: (QA follow-up) receipt -> receive > >Signed-off-by: Kathleen Milne <kathleen.milne@cne-siar.gov.uk> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > Koha/Item/Transfer.pm | 19 ++++++++++ > t/db_dependent/Koha/Item/Transfer.t | 59 ++++++++++++++++++++++++++++- > 2 files changed, 77 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm >index 2928480c0a..0afe12ed1a 100644 >--- a/Koha/Item/Transfer.pm >+++ b/Koha/Item/Transfer.pm >@@ -84,6 +84,25 @@ sub transit { > return $self; > } > >+=head3 receive >+ >+Receive the transfer by setting the datearrived time. >+ >+=cut >+ >+sub receive { >+ my ($self) = @_; >+ >+ # Throw exception if item is checked out >+ Koha::Exceptions::Item::Transfer::Out->throw() if ($self->item->checkout); >+ >+ # Update the arrived date >+ $self->set({ datearrived => dt_from_string })->store; >+ >+ ModDateLastSeen( $self->item->itemnumber ); >+ return $self; >+} >+ > =head3 type > > =cut >diff --git a/t/db_dependent/Koha/Item/Transfer.t b/t/db_dependent/Koha/Item/Transfer.t >index 4b094d80cb..b82e2c8094 100755 >--- a/t/db_dependent/Koha/Item/Transfer.t >+++ b/t/db_dependent/Koha/Item/Transfer.t >@@ -23,7 +23,7 @@ use Koha::Database; > > use t::lib::TestBuilder; > >-use Test::More tests => 2; >+use Test::More tests => 3; > use Test::Exception; > > my $schema = Koha::Database->new->schema; >@@ -112,3 +112,60 @@ subtest 'transit tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'receive tests' => sub { >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $item = $builder->build_sample_item( >+ { >+ homebranch => $library1->branchcode, >+ holdingbranch => $library2->branchcode, >+ datelastseen => undef >+ } >+ ); >+ >+ my $transfer = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $library2->branchcode, >+ tobranch => $library1->branchcode, >+ datearrived => undef, >+ reason => 'Manual' >+ } >+ } >+ ); >+ is( ref($transfer), 'Koha::Item::Transfer', 'Mock transfer added' ); >+ >+ # Item checked out should result in failure >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ itemnumber => $item->itemnumber >+ } >+ } >+ ); >+ is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' ); >+ >+ throws_ok { $transfer->receive() } >+ 'Koha::Exceptions::Item::Transfer::Out', >+ 'Exception thrown if item is checked out'; >+ >+ $checkout->delete; >+ >+ # Transit state set >+ $transfer->discard_changes; >+ $transfer->receive(); >+ ok( $transfer->datearrived, 'Receipt set the datearrived for the transfer' ); >+ >+ # Last seen >+ ok( $item->datelastseen, 'Receipt set item datelastseen date' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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 25767
:
105905
|
105906
|
107244
|
107245
|
107299
|
107300
|
110277
|
110278
|
110299
|
110300
|
110397
|
110398
|
110399
|
110510
|
110511
|
110512
|
116550
|
116551
|
116552
|
117571
| 117583