From b3828176a0d764f9e48e3e34db5b57cd47d30faa Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Mon, 27 Sep 2021 16:48:25 +0200 Subject: [PATCH] Bug 20058: Add tests --- t/db_dependent/SIP/Message.t | 54 ++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 790248b748..04ace15972 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 => 11; +use Test::More tests => 12; use Test::Exception; use Test::MockObject; use Test::MockModule; @@ -95,6 +95,56 @@ subtest 'Test hold_patron_bcode' => sub { $schema->storage->txn_rollback; }; +subtest 'UseLocationAsAQInSIP syspref tests' => sub { + plan tests => 2; + + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin; + + my $builder = t::lib::TestBuilder->new(); + + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my $branchcode_permanent_location = $builder->build({ source => 'Branch' })->{branchcode}; + + my $mocks = create_mocks(\$branchcode, \$branchcode_permanent_location); + + t::lib::Mocks::mock_preference('UseLocationAsAQInSIP', 0); + + my $item = $builder->build_sample_item( + { + damaged => 0, + withdrawn => 0, + itemlost => 0, + restricted => 0, + homebranch => $branchcode, + holdingbranch => $branchcode, + permanent_location => $branchcode_permanent_location + } + ); + + my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + is( $sip_item->permanent_location, $branchcode, "When UseLocationAsAQInSIP is not set SIP item has permanent_location set to value of homebranch" ); + + t::lib::Mocks::mock_preference('UseLocationAsAQInSIP', 1); + + $item = $builder->build_sample_item( + { + damaged => 0, + withdrawn => 0, + itemlost => 0, + restricted => 0, + homebranch => $branchcode, + holdingbranch => $branchcode, + permanent_location => $branchcode_permanent_location + } + ); + + $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); + is( $sip_item->permanent_location, $branchcode_permanent_location, "When UseLocationAsAQInSIP is set SIP item has permanent_location set to value of item permanent_location" ); + + $schema->storage->txn_rollback; +}; + subtest 'hold_patron_name() tests' => sub { plan tests => 2; @@ -106,7 +156,7 @@ subtest 'hold_patron_name() tests' => sub { my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; my ( $response, $findpatron ); - my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); + my $mocks = create_mocks( \$response, \$findpatron, \$branchcode); my $item = $builder->build_sample_item( { -- 2.20.1