|
Lines 92-106
subtest 'hidden_in_opac() tests' => sub {
Link Here
|
| 92 |
$schema->storage->txn_rollback; |
92 |
$schema->storage->txn_rollback; |
| 93 |
}; |
93 |
}; |
| 94 |
|
94 |
|
| 95 |
subtest 'items() and items_count() tests' => sub { |
95 |
subtest 'items() tests' => sub { |
| 96 |
|
96 |
|
| 97 |
plan tests => 5; |
97 |
plan tests => 4; |
| 98 |
|
98 |
|
| 99 |
$schema->storage->txn_begin; |
99 |
$schema->storage->txn_begin; |
| 100 |
|
100 |
|
| 101 |
my $biblio = $builder->build_sample_biblio(); |
101 |
my $biblio = $builder->build_sample_biblio(); |
| 102 |
|
102 |
|
| 103 |
is( $biblio->items_count, 0, 'No items, count is 0' ); |
103 |
is( $biblio->items->count, 0, 'No items, count is 0' ); |
| 104 |
|
104 |
|
| 105 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
105 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
| 106 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
106 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
|
Lines 108-114
subtest 'items() and items_count() tests' => sub {
Link Here
|
| 108 |
my $items = $biblio->items; |
108 |
my $items = $biblio->items; |
| 109 |
is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' ); |
109 |
is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' ); |
| 110 |
is( $items->count, 2, 'Two items in resultset' ); |
110 |
is( $items->count, 2, 'Two items in resultset' ); |
| 111 |
is( $biblio->items_count, $items->count, 'items_count returns the expected value' ); |
|
|
| 112 |
|
111 |
|
| 113 |
my @items = $biblio->items->as_list; |
112 |
my @items = $biblio->items->as_list; |
| 114 |
is( scalar @items, 2, 'Same result, but in list context' ); |
113 |
is( scalar @items, 2, 'Same result, but in list context' ); |
|
Lines 496-514
subtest 'suggestions() tests' => sub {
Link Here
|
| 496 |
$schema->storage->txn_rollback; |
495 |
$schema->storage->txn_rollback; |
| 497 |
}; |
496 |
}; |
| 498 |
|
497 |
|
| 499 |
subtest 'orders() and active_orders_count() tests' => sub { |
498 |
subtest 'orders() and active_orders() tests' => sub { |
| 500 |
|
499 |
|
| 501 |
plan tests => 4; |
500 |
plan tests => 5; |
| 502 |
|
501 |
|
| 503 |
$schema->storage->txn_begin; |
502 |
$schema->storage->txn_begin; |
| 504 |
|
503 |
|
| 505 |
my $biblio = $builder->build_sample_biblio(); |
504 |
my $biblio = $builder->build_sample_biblio(); |
| 506 |
|
505 |
|
| 507 |
my $orders = $biblio->orders; |
506 |
my $orders = $biblio->orders; |
| 508 |
my $active_orders_count = $biblio->active_orders_count; |
507 |
my $active_orders = $biblio->active_orders; |
| 509 |
|
508 |
|
| 510 |
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
509 |
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
| 511 |
is( $orders->count, $active_orders_count, '->orders_count returns the count for the resultset' ); |
510 |
is( $biblio->orders->count, $biblio->active_orders->count, '->orders_count returns the count for the resultset' ); |
| 512 |
|
511 |
|
| 513 |
# Add a couple orders |
512 |
# Add a couple orders |
| 514 |
foreach (1..2) { |
513 |
foreach (1..2) { |
|
Lines 534-550
subtest 'orders() and active_orders_count() tests' => sub {
Link Here
|
| 534 |
); |
533 |
); |
| 535 |
|
534 |
|
| 536 |
$orders = $biblio->orders; |
535 |
$orders = $biblio->orders; |
| 537 |
$active_orders_count = $biblio->active_orders_count; |
536 |
$active_orders = $biblio->active_orders; |
| 538 |
|
537 |
|
| 539 |
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
538 |
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
| 540 |
is( $orders->count, $active_orders_count + 2, '->active_orders_count returns the rigt count' ); |
539 |
is( ref($active_orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
|
|
540 |
is( $orders->count, $active_orders->count + 2, '->active_orders_count returns the rigt count' ); |
| 541 |
|
541 |
|
| 542 |
$schema->storage->txn_rollback; |
542 |
$schema->storage->txn_rollback; |
| 543 |
}; |
543 |
}; |
| 544 |
|
544 |
|
| 545 |
subtest 'subscriptions() and subscriptions_count() tests' => sub { |
545 |
subtest 'subscriptions() tests' => sub { |
| 546 |
|
546 |
|
| 547 |
plan tests => 6; |
547 |
plan tests => 4; |
| 548 |
|
548 |
|
| 549 |
$schema->storage->txn_begin; |
549 |
$schema->storage->txn_begin; |
| 550 |
|
550 |
|
|
Lines 555-561
subtest 'subscriptions() and subscriptions_count() tests' => sub {
Link Here
|
| 555 |
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object' |
555 |
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object' |
| 556 |
); |
556 |
); |
| 557 |
is( $subscriptions->count, 0, 'Koha::Biblio->subscriptions should return the correct number of subscriptions'); |
557 |
is( $subscriptions->count, 0, 'Koha::Biblio->subscriptions should return the correct number of subscriptions'); |
| 558 |
is( $biblio->subscriptions_count, 0, 'subscriptions_count returns the correct number' ); |
|
|
| 559 |
|
558 |
|
| 560 |
# Add two subscriptions |
559 |
# Add two subscriptions |
| 561 |
foreach (1..2) { |
560 |
foreach (1..2) { |
|
Lines 572-578
subtest 'subscriptions() and subscriptions_count() tests' => sub {
Link Here
|
| 572 |
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object' |
571 |
'Koha::Biblio->subscriptions should return a Koha::Subscriptions object' |
| 573 |
); |
572 |
); |
| 574 |
is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions'); |
573 |
is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions'); |
| 575 |
is( $biblio->subscriptions_count, 2, 'subscriptions_count returns the correct number' ); |
|
|
| 576 |
|
574 |
|
| 577 |
$schema->storage->txn_rollback; |
575 |
$schema->storage->txn_rollback; |
| 578 |
}; |
576 |
}; |
| 579 |
- |
|
|