Koha/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t
Jonathan Druart 54bc027289 Bug 17633: Do not call set_preference from tests
If memcached is running, the pref's value will be set in cache, what we
do not want.

t/db_dependent/Context.t and t/db_dependent/sysprefs.t are exceptions
for obvious reasons.

Test plan:
Make sure all these tests still pass

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-11-16 15:31:01 +00:00

68 lines
1.9 KiB
Perl

#!/usr/bin/perl
# 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 t::lib::TestBuilder;
use t::lib::Mocks;
use C4::Accounts qw( manualinvoice );
use C4::Circulation qw( CanBookBeIssued );
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new();
my $item = $builder->build(
{
source => 'Item',
value => {
notforloan => 0,
withdrawn => 0
}
}
);
my $patron = $builder->build(
{
source => 'Borrower',
}
);
my $guarantee = $builder->build(
{
source => 'Borrower',
value => {
guarantorid => $patron->{borrowernumber},
}
}
);
t::lib::Mocks::mock_preference( 'NoIssuesChargeGuarantees', '5.00' );
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" );
manualinvoice( $guarantee->{borrowernumber}, undef, undef, 'L', 10.00 );
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} );
is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" );
$schema->storage->txn_rollback;
1;