Lines 17-27
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 3; |
21 |
use t::lib::TestBuilder; |
21 |
use t::lib::TestBuilder; |
22 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
23 |
|
23 |
|
24 |
use C4::Circulation; |
24 |
use C4::Circulation; |
|
|
25 |
use C4::Reserves; |
25 |
use Koha::DateUtils qw( dt_from_string ); |
26 |
use Koha::DateUtils qw( dt_from_string ); |
26 |
|
27 |
|
27 |
my $builder = t::lib::TestBuilder->new; |
28 |
my $builder = t::lib::TestBuilder->new; |
Lines 31-43
my @got;
Link Here
|
31 |
my @wanted; |
32 |
my @wanted; |
32 |
|
33 |
|
33 |
#Transfert on unknown barcode |
34 |
#Transfert on unknown barcode |
34 |
my $badbc = 'wherethehelldoyoucomefrom'; |
35 |
my $item = $builder->build_sample_item(); |
35 |
@got = C4::Circulation::transferbook( $library->{branchcode}, $badbc ); |
36 |
my $badbc = $item->barcode; |
36 |
@wanted = ( 0, { 'BadBarcode' => $badbc } ); |
37 |
$item->delete; |
37 |
is_deeply( \@got , \@wanted, 'bad barcode case'); |
38 |
|
|
|
39 |
my ( $dotransfer, $messages ) = C4::Circulation::transferbook( $library->{branchcode}, $badbc ); |
40 |
is( $dotransfer, 0, "Can't transfer a bad barcode"); |
41 |
is_deeply( $messages, { BadBarcode => $badbc }, "We got the expected barcode"); |
38 |
|
42 |
|
39 |
subtest 'transfer an issued item' => sub { |
43 |
subtest 'transfer an issued item' => sub { |
40 |
plan tests => 1; |
44 |
plan tests => 3; |
41 |
|
45 |
|
42 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
46 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
43 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); |
47 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); |
Lines 61-66
subtest 'transfer an issued item' => sub {
Link Here
|
61 |
# We are making sure there is no regression, feel free to change the behavior if needed. |
65 |
# We are making sure there is no regression, feel free to change the behavior if needed. |
62 |
# * WasReturned does not seem like a variable that should contain a borrowernumber |
66 |
# * WasReturned does not seem like a variable that should contain a borrowernumber |
63 |
# * Should we return even if the transfer did not happen? (same branches) |
67 |
# * Should we return even if the transfer did not happen? (same branches) |
64 |
my @got = transferbook( $library->branchcode, $item->barcode ); |
68 |
my ($dotransfer, $messages) = transferbook( $library->branchcode, $item->barcode ); |
65 |
is( $got[1]->{WasReturned}, $patron->borrowernumber, 'transferbook should have return a WasReturned flag is the item was issued before the transferbook call'); |
69 |
is( $messages->{WasReturned}, $patron->borrowernumber, 'transferbook should have return a WasReturned flag is the item was issued before the transferbook call'); |
|
|
70 |
|
71 |
AddReserve({ |
72 |
branchcode => $item->homebranch, |
73 |
borrowernumber => $patron->borrowernumber, |
74 |
biblionumber => $item->biblionumber, |
75 |
itemnumber => $item->itemnumber, |
76 |
}); |
77 |
($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); |
78 |
is( $messages->{ResFound}->{ResFound}, 'Reserved', "We found the reserve"); |
79 |
is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info"); |
66 |
}; |
80 |
}; |
67 |
- |
|
|