Lines 17-26
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 2; |
21 |
use t::lib::TestBuilder; |
21 |
use t::lib::TestBuilder; |
|
|
22 |
use t::lib::Mocks; |
22 |
|
23 |
|
23 |
use C4::Circulation; |
24 |
use C4::Circulation; |
|
|
25 |
use Koha::DateUtils qw( dt_from_string ); |
24 |
|
26 |
|
25 |
my $builder = t::lib::TestBuilder->new; |
27 |
my $builder = t::lib::TestBuilder->new; |
26 |
|
28 |
|
Lines 33-35
my $badbc = 'wherethehelldoyoucomefrom';
Link Here
|
33 |
@got = C4::Circulation::transferbook( $library->{branchcode}, $badbc ); |
35 |
@got = C4::Circulation::transferbook( $library->{branchcode}, $badbc ); |
34 |
@wanted = ( 0, { 'BadBarcode' => $badbc } ); |
36 |
@wanted = ( 0, { 'BadBarcode' => $badbc } ); |
35 |
is_deeply( \@got , \@wanted, 'bad barcode case'); |
37 |
is_deeply( \@got , \@wanted, 'bad barcode case'); |
36 |
- |
38 |
|
|
|
39 |
subtest 'transfer an issued item' => sub { |
40 |
plan tests => 1; |
41 |
|
42 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
43 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); |
44 |
|
45 |
my $patron = $builder->build_object( |
46 |
{ |
47 |
class => 'Koha::Patrons', |
48 |
value => { branchcode => $library->branchcode } |
49 |
} |
50 |
); |
51 |
|
52 |
my $item = $builder->build_sample_item( |
53 |
{ |
54 |
library => $library->branchcode, |
55 |
} |
56 |
); |
57 |
|
58 |
my $dt_to = dt_from_string(); |
59 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to ); |
60 |
|
61 |
# 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 |
63 |
# * Should we return even if the transfer did not happen? (same branches) |
64 |
my @got = 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'); |
66 |
}; |