Bug 25619: Unit Tests

Signed-off-by: Abbey Holt <aholt@dubuque.lib.ia.us>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Kyle Hall 2021-07-16 14:26:37 -04:00
parent 00232f0bd7
commit e3e4024354

View file

@ -7,7 +7,7 @@ use t::lib::TestBuilder;
use C4::Context;
use Test::More tests => 71;
use Test::More tests => 72;
use MARC::Record;
use C4::Biblio;
@ -1610,3 +1610,58 @@ subtest 'CanItemBeReserved rule precedence tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'CanItemBeReserved rule precedence tests' => sub {
plan tests => 2;
$schema->storage->txn_begin;
my $category = $builder->build({ source => 'Category' });
my $branch = $builder->build({ source => 'Branch' })->{ branchcode };
my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } );
my $itemnumber = $builder->build_sample_item(
{ library => $branch, biblionumber => $biblio->biblionumber } )
->itemnumber;
my $borrowernumber = Koha::Patron->new(
{
firstname => 'my firstname',
surname => 'my surname ' . $_,
categorycode => $category->{categorycode},
branchcode => $branch,
}
)->store->borrowernumber;
my $reserve_id = AddReserve(
{
branchcode => $branch,
borrowernumber => $borrowernumber,
biblionumber => $biblio->biblionumber,
priority =>
C4::Reserves::CalculatePriority( $biblio->biblionumber ),
itemnumber => $itemnumber,
}
);
my $hold = Koha::Holds->find($reserve_id);
$hold->set( { priority => 0, found => 'W' } )->store();
ModReserve(
{
reserve_id => $hold->id,
expirationdate => '1981-06-10',
priority => 99,
rank => 0,
}
);
$hold = Koha::Holds->find($reserve_id);
is( $hold->expirationdate, '1981-06-10',
'Found hold expiration date updated correctly' );
is( $hold->priority, '0', 'Found hold priority was not updated' );
$schema->storage->txn_rollback;
};