|
Lines 18-24
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
use utf8; |
19 |
use utf8; |
| 20 |
|
20 |
|
| 21 |
use Test::More tests => 49; |
21 |
use Test::More tests => 50; |
| 22 |
use Test::Exception; |
22 |
use Test::Exception; |
| 23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
| 24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
|
Lines 4060-4065
subtest 'transferbook tests' => sub {
Link Here
|
| 4060 |
|
4060 |
|
| 4061 |
}; |
4061 |
}; |
| 4062 |
|
4062 |
|
|
|
4063 |
subtest 'Checkout should correctly terminate a transfer' => sub { |
| 4064 |
plan tests => 7; |
| 4065 |
|
| 4066 |
my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 4067 |
my $patron_1 = $builder->build_object( |
| 4068 |
{ |
| 4069 |
class => 'Koha::Patrons', |
| 4070 |
value => { branchcode => $library_1->branchcode } |
| 4071 |
} |
| 4072 |
); |
| 4073 |
my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 4074 |
my $patron_2 = $builder->build_object( |
| 4075 |
{ |
| 4076 |
class => 'Koha::Patrons', |
| 4077 |
value => { branchcode => $library_2->branchcode } |
| 4078 |
} |
| 4079 |
); |
| 4080 |
|
| 4081 |
my $item = $builder->build_sample_item( |
| 4082 |
{ |
| 4083 |
library => $library_1->branchcode, |
| 4084 |
} |
| 4085 |
); |
| 4086 |
|
| 4087 |
t::lib::Mocks::mock_userenv( { branchcode => $library_1->branchcode } ); |
| 4088 |
my $reserve_id = AddReserve( |
| 4089 |
{ |
| 4090 |
branchcode => $library_2->branchcode, |
| 4091 |
borrowernumber => $patron_2->borrowernumber, |
| 4092 |
biblionumber => $item->biblionumber, |
| 4093 |
itemnumber => $item->itemnumber, |
| 4094 |
priority => 1, |
| 4095 |
} |
| 4096 |
); |
| 4097 |
|
| 4098 |
my $do_transfer = 1; |
| 4099 |
ModItemTransfer( $item->itemnumber, $library_1->branchcode, |
| 4100 |
$library_2->branchcode ); |
| 4101 |
ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); |
| 4102 |
GetOtherReserves( $item->itemnumber ) |
| 4103 |
; # To put the Reason, it's what does returns.pl... |
| 4104 |
my $hold = Koha::Holds->find($reserve_id); |
| 4105 |
is( $hold->found, 'T', 'Hold is in transit' ); |
| 4106 |
my $transfer = $item->get_transfer; |
| 4107 |
is( $transfer->frombranch, $library_1->branchcode ); |
| 4108 |
is( $transfer->tobranch, $library_2->branchcode ); |
| 4109 |
is( $transfer->reason, 'Reserve' ); |
| 4110 |
|
| 4111 |
t::lib::Mocks::mock_userenv( { branchcode => $library_2->branchcode } ); |
| 4112 |
AddIssue( $patron_1->unblessed, $item->barcode ); |
| 4113 |
$transfer = $transfer->get_from_storage; |
| 4114 |
isnt( $transfer->datearrived, undef ); |
| 4115 |
$hold = $hold->get_from_storage; |
| 4116 |
is( $hold->found, undef, 'Hold is waiting' ); |
| 4117 |
is( $hold->priority, 1, ); |
| 4118 |
}; |
| 4119 |
|
| 4063 |
$schema->storage->txn_rollback; |
4120 |
$schema->storage->txn_rollback; |
| 4064 |
C4::Context->clear_syspref_cache(); |
4121 |
C4::Context->clear_syspref_cache(); |
| 4065 |
$branches = Koha::Libraries->search(); |
4122 |
$branches = Koha::Libraries->search(); |
| 4066 |
- |
|
|