Bug 17229: Move tests to t/db_dependant/ILSDI_Service.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

JD Amended commit message
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Arthur Suzuki 2020-02-27 14:45:17 +01:00 committed by Jonathan Druart
parent 9c3f267350
commit 5f595aab02
2 changed files with 36 additions and 20 deletions

View File

@ -43,12 +43,7 @@ my $dbh = C4::Context->dbh;
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode };
my $category = $builder->build({
source => 'Category',
value => {
BlockExpiredPatronOpacActions => -1,
},
});
my $category = $builder->build({ source => 'Category' });
my $borrowers_count = 5;
@ -132,19 +127,6 @@ my $patron = Koha::Patrons->find( $borrowernumbers[0] );
$holds = $patron->holds;
is( $holds->next->borrowernumber, $borrowernumbers[0], "Test Koha::Patron->holds");
my $expired_borrowernumber = Koha::Patron->new({
firstname => 'Expired',
surname => 'Patron',
categorycode => $category->{categorycode},
branchcode => $branch_1,
dateexpiry => '2000-01-01',
})->store->borrowernumber;
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
ok(
CanItemBeReserved($expired_borrowernumber, $itemnumber)->{status} eq 'patronExpired',
'Expired patron cannot reserve'
);
$holds = $item->current_holds;
$first_hold = $holds->next;

View File

@ -300,7 +300,7 @@ subtest 'LookupPatron test' => sub {
subtest 'Holds test' => sub {
plan tests => 7;
plan tests => 8;
$schema->storage->txn_begin;
@ -427,6 +427,40 @@ subtest 'Holds test' => sub {
is( $reply->{code}, 'alreadypossession', "Patron has issued same book" );
is( $reply->{pickup_location}, undef, "No reserve placed");
# Test Patron cannot reserve if expired and BlockExpiredPatronOpacActions
my $category = $builder->build({
source => 'Category',
value => { BlockExpiredPatronOpacActions => -1 }
});
my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
my $expired_borrowernumber = Koha::Patron->new({
firstname => 'Expired',
surname => 'Patron',
categorycode => $category->{categorycode},
branchcode => $branch_1,
dateexpiry => '2000-01-01',
})->store->borrowernumber;
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
my $item5 = $builder->build({
source => 'Item',
value => {
biblionumber => $biblio_with_no_item->{biblionumber},
damaged => 0,
}
});
$query = new CGI;
$query->param( 'patron_id', $expired_borrowernumber);
$query->param( 'bib_id', $biblio_with_no_item->{biblionumber});
$query->param( 'item_id', $item5->{itemnumber});
$reply = C4::ILSDI::Services::HoldItem( $query );
is( $reply->{code}, 'PatronExpired', "Patron is expired" );
$schema->storage->txn_rollback;
};