Lines 146-151
subtest 'ModItem tests' => sub {
Link Here
|
146 |
|
146 |
|
147 |
}; |
147 |
}; |
148 |
|
148 |
|
|
|
149 |
subtest 'ModItemTransfer tests' => sub { |
150 |
plan tests => 8; |
151 |
|
152 |
$schema->storage->txn_begin; |
153 |
|
154 |
my $builder = t::lib::TestBuilder->new; |
155 |
my $item = $builder->build_object( |
156 |
{ |
157 |
class => 'Koha::Items', |
158 |
value => { |
159 |
itemlost => 0, |
160 |
damaged => 0, |
161 |
withdrawn => 0, |
162 |
itemlost_on => undef, |
163 |
damaged_on => undef, |
164 |
withdrawn_on => undef, |
165 |
} |
166 |
} |
167 |
)->store; |
168 |
|
169 |
my $library1 = $builder->build( |
170 |
{ |
171 |
source => 'Branch', |
172 |
} |
173 |
); |
174 |
my $library2 = $builder->build( |
175 |
{ |
176 |
source => 'Branch', |
177 |
} |
178 |
); |
179 |
|
180 |
ModItemTransfer( $item->itemnumber, $library1->{branchcode}, |
181 |
$library2->{branchcode} ); |
182 |
|
183 |
my $transfers = Koha::Item::Transfers->search( |
184 |
{ |
185 |
itemnumber => $item->itemnumber |
186 |
} |
187 |
); |
188 |
|
189 |
is( $transfers->count, 1, "One transfer created with ModItemTransfer" ); |
190 |
$item->discard_changes; |
191 |
is($item->holdingbranch, $library1->{branchcode}, "Items holding branch was updated to frombranch"); |
192 |
|
193 |
ModItemTransfer( $item->itemnumber, $library2->{branchcode}, |
194 |
$library1->{branchcode} ); |
195 |
$transfers = Koha::Item::Transfers->search( |
196 |
{ itemnumber => $item->itemnumber, }, |
197 |
{ order_by => { '-asc' => 'branchtransfer_id' } } |
198 |
); |
199 |
|
200 |
is($transfers->count, 2, "Second transfer recorded on second call of ModItemTransfer"); |
201 |
my $transfer1 = $transfers->next; |
202 |
my $transfer2 = $transfers->next; |
203 |
isnt($transfer1->datearrived, undef, "First transfer marked as completed by ModItemTransfer"); |
204 |
like($transfer1->comments,qr/^Canceled/, "First transfer contains 'Canceled' comment"); |
205 |
is($transfer2->datearrived, undef, "Second transfer is now the active transfer"); |
206 |
$item->discard_changes; |
207 |
is($item->holdingbranch, $library2->{branchcode}, "Items holding branch was updated to frombranch"); |
208 |
|
209 |
# Check 'reason' is populated when passed |
210 |
ModItemTransfer( $item->itemnumber, $library2->{branchcode}, |
211 |
$library1->{branchcode}, "Manual" ); |
212 |
|
213 |
$transfers = Koha::Item::Transfers->search( |
214 |
{ itemnumber => $item->itemnumber, }, |
215 |
{ order_by => { '-desc' => 'branchtransfer_id' } } |
216 |
); |
217 |
|
218 |
my $transfer3 = $transfers->next; |
219 |
is($transfer3->reason, 'Manual', "Reason set via ModItemTransfer"); |
220 |
|
221 |
$schema->storage->txn_rollback; |
222 |
}; |
223 |
|
149 |
subtest 'GetHiddenItemnumbers tests' => sub { |
224 |
subtest 'GetHiddenItemnumbers tests' => sub { |
150 |
|
225 |
|
151 |
plan tests => 11; |
226 |
plan tests => 11; |
152 |
- |
|
|