Bugzilla – Attachment 117925 Details for
Bug 27281
Replace call to `C4::Circulation::DeleteTransfer` with `Koha::Item::Transfer->cancel({ comment => $comment })` in `C4::Circulation::LostItem`
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27281: Add unit test for Koha::Item->get_transfers
Bug-27281-Add-unit-test-for-KohaItem-gettransfers.patch (text/plain), 5.67 KB, created by
Martin Renvoize (ashimema)
on 2021-03-08 15:01:35 UTC
(
hide
)
Description:
Bug 27281: Add unit test for Koha::Item->get_transfers
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-08 15:01:35 UTC
Size:
5.67 KB
patch
obsolete
>From c9b67dc66fba6f2ff7eeb235ddadc505c14c395a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 8 Mar 2021 14:14:20 +0000 >Subject: [PATCH] Bug 27281: Add unit test for Koha::Item->get_transfers > >In the previous patch we introduced the new get_transfers method to the >Koha::Item object. This patch adds proper unit tests for that addition. > >Test plan >1/ Apply patches and confirm t/db_dependent/Koha/Item.t passes. >2/ Signoff >--- > t/db_dependent/Koha/Item.t | 101 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 100 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 06a9a6ef52..fcb1891405 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 9; > use Test::Exception; > > use C4::Biblio; >@@ -691,3 +691,102 @@ subtest 'Tests for itemtype' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'get_transfers' => sub { >+ plan tests => 16; >+ $schema->storage->txn_begin; >+ >+ my $item = $builder->build_sample_item(); >+ >+ my $transfers = $item->get_transfers(); >+ is(ref($transfers), 'Koha::Item::Transfers', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' ); >+ is($transfers->count, 0, 'When no transfers exist, the Koha::Item:Transfers object should be empty'); >+ >+ my $library_to = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $transfer_1 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $item->holdingbranch, >+ tobranch => $library_to->branchcode, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ >+ $transfers = $item->get_transfers(); >+ is($transfers->count, 1, 'When one transfer has been reqeusted, the Koha::Item:Transfers object should contain one result'); >+ >+ my $transfer_2 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $item->holdingbranch, >+ tobranch => $library_to->branchcode, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ >+ my $transfer_3 = $builder->build_object( >+ { >+ class => 'Koha::Item::Transfers', >+ value => { >+ itemnumber => $item->itemnumber, >+ frombranch => $item->holdingbranch, >+ tobranch => $library_to->branchcode, >+ reason => 'Manual', >+ datesent => undef, >+ datearrived => undef, >+ datecancelled => undef, >+ daterequested => \'NOW()' >+ } >+ } >+ ); >+ >+ $transfers = $item->get_transfers(); >+ is($transfers->count, 3, 'When there are multiple open transfer requests, the Koha::Item::Transfers object contains them all'); >+ my $result_1 = $transfers->next; >+ my $result_2 = $transfers->next; >+ my $result_3 = $transfers->next; >+ is( $result_1->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfers returns the oldest transfer request first'); >+ is( $result_2->branchtransfer_id, $transfer_2->branchtransfer_id, 'Koha::Item->get_transfers returns the newer transfer request second'); >+ is( $result_3->branchtransfer_id, $transfer_3->branchtransfer_id, 'Koha::Item->get_transfers returns the newest transfer request last'); >+ >+ $transfer_2->datesent(\'NOW()')->store; >+ $transfers = $item->get_transfers(); >+ is($transfers->count, 3, 'When one transfer is set to in_transit, the Koha::Item::Transfers object still contains them all'); >+ $result_1 = $transfers->next; >+ $result_2 = $transfers->next; >+ $result_3 = $transfers->next; >+ is( $result_1->branchtransfer_id, $transfer_2->branchtransfer_id, 'Koha::Item->get_transfers returns the active transfer request first'); >+ is( $result_2->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfers returns the other transfers oldest to newest'); >+ is( $result_3->branchtransfer_id, $transfer_3->branchtransfer_id, 'Koha::Item->get_transfers returns the other transfers oldest to newest'); >+ >+ $transfer_2->datearrived(\'NOW()')->store; >+ $transfers = $item->get_transfers(); >+ is($transfers->count, 2, 'Once a transfer is recieved, it no longer appears in the list from ->get_transfers()'); >+ $result_1 = $transfers->next; >+ $result_2 = $transfers->next; >+ is( $result_1->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfers returns the other transfers oldest to newest'); >+ is( $result_2->branchtransfer_id, $transfer_3->branchtransfer_id, 'Koha::Item->get_transfers returns the other transfers oldest to newest'); >+ >+ $transfer_1->datecancelled(\'NOW()')->store; >+ $transfers = $item->get_transfers(); >+ is($transfers->count, 1, 'Once a transfer is cancelled, it no longer appears in the list from ->get_transfers()'); >+ $result_1 = $transfers->next; >+ is( $result_1->branchtransfer_id, $transfer_3->branchtransfer_id, 'Koha::Item->get_transfers returns the only transfer that remains'); >+ >+ $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 27281
:
117921
|
117922
|
117924
|
117925
|
117926
|
119754
|
119755
|
119756
|
119757
|
119847
|
119848
|
119849
|
119850
|
119986
|
120105
|
120107
|
120117