Lines 18-23
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use File::Basename qw/basename/; |
20 |
use File::Basename qw/basename/; |
|
|
21 |
|
22 |
use C4::Circulation qw(AddIssue AddReturn); |
23 |
|
21 |
use Koha::Database; |
24 |
use Koha::Database; |
22 |
use Koha::Illrequestattributes; |
25 |
use Koha::Illrequestattributes; |
23 |
use Koha::Illrequest::Config; |
26 |
use Koha::Illrequest::Config; |
Lines 36-42
use Test::Exception;
Link Here
|
36 |
use Test::Deep qw/ cmp_deeply ignore /; |
39 |
use Test::Deep qw/ cmp_deeply ignore /; |
37 |
use Test::Warn; |
40 |
use Test::Warn; |
38 |
|
41 |
|
39 |
use Test::More tests => 12; |
42 |
use Test::More tests => 13; |
40 |
|
43 |
|
41 |
my $schema = Koha::Database->new->schema; |
44 |
my $schema = Koha::Database->new->schema; |
42 |
my $builder = t::lib::TestBuilder->new; |
45 |
my $builder = t::lib::TestBuilder->new; |
Lines 1160-1162
subtest 'Custom statuses' => sub {
Link Here
|
1160 |
|
1163 |
|
1161 |
$schema->storage->txn_rollback; |
1164 |
$schema->storage->txn_rollback; |
1162 |
}; |
1165 |
}; |
1163 |
- |
1166 |
|
|
|
1167 |
subtest 'Checking in hook' => sub { |
1168 |
|
1169 |
plan tests => 2; |
1170 |
|
1171 |
$schema->storage->txn_begin; |
1172 |
|
1173 |
# Build infrastructure |
1174 |
my $backend = Test::MockObject->new; |
1175 |
$backend->set_isa('Koha::Illbackends::Mock'); |
1176 |
$backend->set_always('name', 'Mock'); |
1177 |
|
1178 |
my $config = Test::MockObject->new; |
1179 |
$config->set_always('backend_dir', "/tmp"); |
1180 |
|
1181 |
my $item = $builder->build_sample_item(); |
1182 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
1183 |
|
1184 |
t::lib::Mocks::mock_userenv( |
1185 |
{ |
1186 |
patron => $patron, |
1187 |
branchcode => $patron->branchcode |
1188 |
} |
1189 |
); |
1190 |
|
1191 |
my $illrq = $builder->build_object( |
1192 |
{ |
1193 |
class => 'Koha::Illrequests', |
1194 |
value => { |
1195 |
biblio_id => $item->biblio->biblionumber, |
1196 |
status => 'NEW' |
1197 |
} |
1198 |
} |
1199 |
); |
1200 |
|
1201 |
$illrq->_config($config); |
1202 |
$illrq->_backend($backend); |
1203 |
|
1204 |
t::lib::Mocks::mock_preference('CirculateILL', 1); |
1205 |
|
1206 |
# Add an issue |
1207 |
AddIssue( $patron->unblessed, $item->barcode ); |
1208 |
# Make the item withdrawn so checking-in is rejected |
1209 |
t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems', 1); |
1210 |
$item->set({ withdrawn => 1 })->store; |
1211 |
AddReturn( $item->barcode, $patron->branchcode ); |
1212 |
# refresh request |
1213 |
$illrq->discard_changes; |
1214 |
isnt( $illrq->status, 'RET' ); |
1215 |
|
1216 |
# allow the check-in |
1217 |
$item->set({ withdrawn => 0 })->store; |
1218 |
AddReturn( $item->barcode, $patron->branchcode ); |
1219 |
# refresh request |
1220 |
$illrq->discard_changes; |
1221 |
is( $illrq->status, 'RET' ); |
1222 |
|
1223 |
$schema->storage->txn_rollback; |
1224 |
}; |