Bug 26114: Regression tests

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 8b106ed9c4)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2020-07-31 11:14:09 -03:00 committed by Lucas Gass
parent 010f8a5885
commit c2a765959a
1 changed files with 63 additions and 1 deletions

View File

@ -18,6 +18,9 @@
use Modern::Perl;
use File::Basename qw/basename/;
use C4::Circulation qw(AddIssue AddReturn);
use Koha::Database;
use Koha::Illrequestattributes;
use Koha::Illrequest::Config;
@ -36,7 +39,7 @@ use Test::Exception;
use Test::Deep qw/ cmp_deeply ignore /;
use Test::Warn;
use Test::More tests => 12;
use Test::More tests => 13;
my $schema = Koha::Database->new->schema;
my $builder = t::lib::TestBuilder->new;
@ -1160,3 +1163,62 @@ subtest 'Custom statuses' => sub {
$schema->storage->txn_rollback;
};
subtest 'Checking in hook' => sub {
plan tests => 2;
$schema->storage->txn_begin;
# Build infrastructure
my $backend = Test::MockObject->new;
$backend->set_isa('Koha::Illbackends::Mock');
$backend->set_always('name', 'Mock');
my $config = Test::MockObject->new;
$config->set_always('backend_dir', "/tmp");
my $item = $builder->build_sample_item();
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
t::lib::Mocks::mock_userenv(
{
patron => $patron,
branchcode => $patron->branchcode
}
);
my $illrq = $builder->build_object(
{
class => 'Koha::Illrequests',
value => {
biblio_id => $item->biblio->biblionumber,
status => 'NEW'
}
}
);
$illrq->_config($config);
$illrq->_backend($backend);
t::lib::Mocks::mock_preference('CirculateILL', 1);
# Add an issue
AddIssue( $patron->unblessed, $item->barcode );
# Make the item withdrawn so checking-in is rejected
t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1);
$item->set({ withdrawn => 1 })->store;
AddReturn( $item->barcode, $patron->branchcode );
# refresh request
$illrq->discard_changes;
isnt( $illrq->status, 'RET' );
# allow the check-in
$item->set({ withdrawn => 0 })->store;
AddReturn( $item->barcode, $patron->branchcode );
# refresh request
$illrq->discard_changes;
is( $illrq->status, 'RET' );
$schema->storage->txn_rollback;
};