Bug 20058: Add tests

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
David Gustafsson 2021-09-27 16:48:25 +02:00 committed by Tomas Cohen Arazi
parent e95e18b21b
commit 66d2696b3e
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -21,7 +21,7 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 13;
use Test::More tests => 14;
use Test::Exception;
use Test::MockObject;
use Test::MockModule;
@ -113,6 +113,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 => 3;