Bugzilla – Attachment 118297 Details for
Bug 24295
C4::Circulation::GetTransfers should be removed, use Koha::Item->get_transfer instead
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.72 KB, created by
Martin Renvoize (ashimema)
on 2021-03-16 11:01:20 UTC
(
hide
)
Description:
Bug 27281: Add unit test for Koha::Item->get_transfers
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-16 11:01:20 UTC
Size:
5.72 KB
patch
obsolete
>From 106ac1f9b6dd512647e632c65f9e7ba8df800c70 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 > >https://bugs.koha-community.org/show_bug.cgi?id=24295 >--- > 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..0c07478029 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 24295
:
118242
|
118243
|
118244
|
118245
|
118246
|
118247
|
118248
|
118249
|
118250
|
118287
|
118295
|
118296
|
118297
|
118298
|
118299
|
118300
|
118301
|
118302
|
118303
|
118304
|
118305
|
118306
|
118307
|
118308
|
118309
|
118310
|
119854
|
119855
|
119856
|
119857
|
119858
|
119859
|
119860
|
119861
|
119862
|
119863
|
119864
|
119866
|
119867
|
127465
|
127466
|
127467
|
127468
|
127469
|
127470
|
127471
|
127472
|
127473
|
127474
|
127475
|
127476
|
127477
|
130430
|
130431
|
130432
|
130433
|
130434
|
130435
|
130436
|
130437
|
130438
|
130439
|
130440
|
130441
|
130442
|
139546
|
139547
|
139548
|
139549
|
139550
|
139551
|
139552
|
139553
|
139554
|
139555
|
139556
|
139557
|
139558
|
139655
|
139656
|
139657
|
139658
|
139659
|
139660
|
139661
|
139662
|
139663
|
139664
|
139665
|
139666
|
139667