Bugzilla – Attachment 54395 Details for
Bug 16686
Fix "Item in transit from since" in Holds tab
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16686: Add test for Koha::Item::Transfer[s] and Koha::Item->get_transfer
Bug-16686-Add-test-for-KohaItemTransfers-and-KohaI.patch (text/plain), 6.59 KB, created by
Nick Clemens (kidclamp)
on 2016-08-12 17:49:09 UTC
(
hide
)
Description:
Bug 16686: Add test for Koha::Item::Transfer[s] and Koha::Item->get_transfer
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-08-12 17:49:09 UTC
Size:
6.59 KB
patch
obsolete
>From 3026db2a417638f2333d5f5158218ed060d17743 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 7 Jul 2016 18:07:32 +0100 >Subject: [PATCH] Bug 16686: Add test for Koha::Item::Transfer[s] and > Koha::Item->get_transfer > >Signed-off-by: Marc <veron@veron.ch> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Item/Transfers.t | 69 ++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Items.t | 82 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 151 insertions(+) > create mode 100644 t/db_dependent/Koha/Item/Transfers.t > create mode 100644 t/db_dependent/Koha/Items.t > >diff --git a/t/db_dependent/Koha/Item/Transfers.t b/t/db_dependent/Koha/Item/Transfers.t >new file mode 100644 >index 0000000..635c9a4 >--- /dev/null >+++ b/t/db_dependent/Koha/Item/Transfers.t >@@ -0,0 +1,69 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 Koha Development team >+# >+# 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 Test::More tests => 2; >+ >+use Koha::Item::Transfer; >+use Koha::Item::Transfers; >+use Koha::Database; >+use Koha::DateUtils; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $library_from = $builder->build( { source => 'Branch' } ); >+my $library_to = $builder->build( { source => 'Branch' } ); >+my $item = $builder->build( { source => 'Item', value => { holding_branch => $library_from->{branchcode}, homebranch => $library_to->{branchcode} } } ); >+ >+my $nb_of_transfers = Koha::Item::Transfers->search->count; >+my $new_transfer_1 = Koha::Item::Transfer->new( >+ { itemnumber => $item->{itemnumber}, >+ frombranch => $library_from->{branchcode}, >+ tobranch => $library_to->{branchcode}, >+ datearrived => dt_from_string, >+ datesent => dt_from_string, >+ } >+)->store; >+my $new_transfer_2 = Koha::Item::Transfer->new( >+ { itemnumber => $item->{itemnumber}, >+ frombranch => $library_from->{branchcode}, >+ tobranch => $library_to->{branchcode}, >+ datearrived => undef, >+ datesent => dt_from_string, >+ } >+)->store; >+ >+is( Koha::Item::Transfers->search->count, $nb_of_transfers + 2, 'The 2 transfers should have been added' ); >+ >+my $retrieved_transfer_1 = Koha::Item::Transfers->search( { itemnumber => $new_transfer_1->itemnumber })->next; >+is( $retrieved_transfer_1->itemnumber, $new_transfer_1->itemnumber, 'Find a transfer by id should return the correct transfer' ); >+ >+# FIXME: This does not pass and should be fixed later >+# "Operation requires a primary key to be declared on 'Branchtransfer' via set_primary_key" >+#$retrieved_transfer_1->delete; >+#is( Koha::Item::Transfers->search->count, $nb_of_transfers + 1, 'Delete should have deleted the transfer' ); >+ >+$schema->storage->txn_rollback; >+ >+1; >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >new file mode 100644 >index 0000000..843bf44 >--- /dev/null >+++ b/t/db_dependent/Koha/Items.t >@@ -0,0 +1,82 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 Koha Development team >+# >+# 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 Test::More tests => 5; >+ >+use C4::Circulation; >+use Koha::Item; >+use Koha::Items; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >+my $library = $builder->build( { source => 'Branch' } ); >+my $nb_of_items = Koha::Items->search->count; >+my $new_item_1 = Koha::Item->new( >+ { biblionumber => $biblioitem->{biblionumber}, >+ biblioitemnumber => $biblioitem->{biblioitemnumber}, >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ barcode => "a_barcode_for_t", >+ } >+)->store; >+my $new_item_2 = Koha::Item->new( >+ { biblionumber => $biblioitem->{biblionumber}, >+ biblioitemnumber => $biblioitem->{biblioitemnumber}, >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ barcode => "another_barcode_for_t", >+ } >+)->store; >+ >+like( $new_item_1->itemnumber, qr|^\d+$|, 'Adding a new item should have set the itemnumber' ); >+is( Koha::Items->search->count, $nb_of_items + 2, 'The 2 items should have been added' ); >+ >+my $retrieved_item_1 = Koha::Items->find( $new_item_1->itemnumber ); >+is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' ); >+ >+subtest 'get_transfer' => sub { >+ plan tests => 3; >+ >+ my $transfer = $new_item_1->get_transfer(); >+ is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item is not in transit' ); >+ >+ my $library_to = $builder->build( { source => 'Branch' } ); >+ >+ C4::Circulation::transferbook( $library_to->{branchcode}, $new_item_1->barcode ); >+ >+ $transfer = $new_item_1->get_transfer(); >+ is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' ); >+ >+ is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' ); >+}; >+ >+$retrieved_item_1->delete; >+is( Koha::Items->search->count, $nb_of_items + 1, 'Delete should have deleted the item' ); >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.1.4
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 16686
:
52157
|
52163
|
52164
|
52183
|
52898
|
53050
|
53053
|
53084
|
53190
|
53191
|
53192
|
53227
|
54128
|
54129
|
54130
|
54131
|
54392
|
54393
|
54394
| 54395