Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 4; |
20 |
use Test::More tests => 5; |
21 |
use t::lib::TestBuilder; |
21 |
use t::lib::TestBuilder; |
22 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
23 |
|
23 |
|
Lines 47-52
subtest 'transfer a non-existant item' => sub {
Link Here
|
47 |
); |
47 |
); |
48 |
}; |
48 |
}; |
49 |
|
49 |
|
|
|
50 |
subtest 'field population tests' => sub { |
51 |
plan tests => 5; |
52 |
|
53 |
my $dbh = C4::Context->dbh; |
54 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
55 |
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); |
56 |
|
57 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
58 |
|
59 |
my $patron = $builder->build_object( |
60 |
{ |
61 |
class => 'Koha::Patrons', |
62 |
value => { branchcode => $library->branchcode } |
63 |
} |
64 |
); |
65 |
|
66 |
my $item = $builder->build_sample_item( |
67 |
{ |
68 |
library => $library->branchcode, |
69 |
} |
70 |
); |
71 |
|
72 |
my $trigger = "Manual"; |
73 |
my ($dotransfer, $messages ) = transferbook( $library2->branchcode, $item->barcode, undef, $trigger ); |
74 |
is( $dotransfer, 1, 'Transfer succeeded' ); |
75 |
is_deeply( |
76 |
$messages, |
77 |
{ 'WasTransfered' => 1 }, |
78 |
"WasTransfered was set correctly" |
79 |
); |
80 |
|
81 |
my $query = ' |
82 |
SELECT datesent, |
83 |
frombranch, |
84 |
tobranch, |
85 |
reason |
86 |
FROM branchtransfers |
87 |
WHERE itemnumber = ? |
88 |
AND datearrived IS NULL |
89 |
'; |
90 |
my $sth = $dbh->prepare($query); |
91 |
$sth->execute($item->itemnumber); |
92 |
my ($datesent, $frombranch, $tobranch, $reason) = $sth->fetchrow_array(); |
93 |
is ($frombranch, $library->branchcode, 'frombranch set correctly'); |
94 |
is ($tobranch, $library2->branchcode, 'tobranch set correctly'); |
95 |
is ($reason, $trigger, 'reason set if passed'); |
96 |
}; |
97 |
|
50 |
#FIXME:'UseBranchTransferLimits tests missing |
98 |
#FIXME:'UseBranchTransferLimits tests missing |
51 |
|
99 |
|
52 |
subtest 'transfer already at destination' => sub { |
100 |
subtest 'transfer already at destination' => sub { |
Lines 69-75
subtest 'transfer already at destination' => sub {
Link Here
|
69 |
); |
117 |
); |
70 |
|
118 |
|
71 |
my ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); |
119 |
my ($dotransfer, $messages ) = transferbook( $library->branchcode, $item->barcode ); |
72 |
is( $dotransfer, 0, 'Transfer of reserved item failed with ignore reserves: true' ); |
120 |
is( $dotransfer, 0, 'Transfer of item failed when destination equals holding branch' ); |
73 |
is_deeply( |
121 |
is_deeply( |
74 |
$messages, |
122 |
$messages, |
75 |
{ 'DestinationEqualsHolding' => 1 }, |
123 |
{ 'DestinationEqualsHolding' => 1 }, |
76 |
- |
|
|