From 0d9303135f92f46ba9ac4b1b2eaf19bf2be5b118 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 10 Apr 2020 06:43:51 -0400 Subject: [PATCH] Bug 24966: Add unit tests Signed-off-by: Kyle M Hall --- t/db_dependent/SIP/Message.t | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 2cdeba73d6..bc8e87a4b3 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -21,7 +21,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use Test::MockObject; use Test::MockModule; use Test::Warn; @@ -73,6 +73,15 @@ subtest 'Checkin V2' => sub { $schema->storage->txn_rollback; }; +subtest 'Test hold_patron_bcode' => sub { + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin; + plan tests => 2; + $C4::SIP::Sip::protocol_version = 2; + test_hold_patron_bcode(); + $schema->storage->txn_rollback; +}; + subtest 'Lastseen response' => sub { my $schema = Koha::Database->new->schema; @@ -468,6 +477,27 @@ sub test_checkin_v2 { 'Issue record is gone now' ); } +sub test_hold_patron_bcode { + my $builder = t::lib::TestBuilder->new(); + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my ( $response, $findpatron ); + my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); + + my $item = $builder->build({ + source => 'Item', + value => { damaged => 0, withdrawn => 0, itemlost => 0, restricted => 0, homebranch => $branchcode, holdingbranch => $branchcode }, + }); + my $item_object = Koha::Items->find( $item->{itemnumber} ); + + my $server = { ils => $mocks->{ils} }; + my $sip_item = C4::SIP::ILS::Item->new( $item->{barcode} ); + + is( $sip_item->hold_patron_bcode, q{}, "SIP item with no hold returns empty string" ); + + my $resp .= C4::SIP::Sip::maybe_add( FID_CALL_NUMBER, $sip_item->hold_patron_bcode, $server ); + is( $resp, q{}, "maybe_add returns empty string for SIP item with no hold returns empty string" ); +} + # Helper routines sub create_mocks { -- 2.24.1 (Apple Git-126)