Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
Lines 250-252
subtest 'duplicate_to | add_item' => sub {
Link Here
|
250 |
|
250 |
|
251 |
$schema->storage->txn_rollback; |
251 |
$schema->storage->txn_rollback; |
252 |
}; |
252 |
}; |
253 |
- |
253 |
|
|
|
254 |
subtest 'holds() and holds_count() tests' => sub { |
255 |
|
256 |
plan tests => 8; |
257 |
|
258 |
$schema->storage->txn_begin; |
259 |
|
260 |
my $biblio = $builder->build_sample_biblio; |
261 |
my $order = $builder->build_object( |
262 |
{ |
263 |
class => 'Koha::Acquisition::Orders', |
264 |
value => { biblionumber => $biblio->biblionumber } |
265 |
} |
266 |
); |
267 |
|
268 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
269 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
270 |
|
271 |
# Associate items to the order |
272 |
$order->add_item( $item_1->itemnumber ); |
273 |
$order->add_item( $item_2->itemnumber ); |
274 |
|
275 |
my $holds = $order->holds; |
276 |
my @holds = $order->holds; |
277 |
is( ref($holds), 'Koha::Holds', 'Type is correct in scalar context' ); |
278 |
is( scalar @holds, 0, 'Count is correct list context' ); |
279 |
is( $holds->count, 0, 'No holds' ); |
280 |
is( $order->holds_count, 0, 'holds_count is consistent' ); |
281 |
|
282 |
# Add a hold |
283 |
$builder->build_object({ class => 'Koha::Holds', value => { itemnumber => $item_1->itemnumber } }); |
284 |
|
285 |
$holds = $order->holds; |
286 |
@holds = $order->holds; |
287 |
is( scalar @holds, 1, 'Count is correct list context' ); |
288 |
is( $holds->count, 1, 'Count is correct in scalar context' ); |
289 |
is( $order->holds_count, 1, 'holds_count is consistent' ); |
290 |
is( ref($holds[0]), 'Koha::Hold', 'Type is correct for individual holds in list context' ); |
291 |
|
292 |
$schema->storage->txn_rollback; |
293 |
}; |