|
Lines 17-26
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 10; |
20 |
use Test::More tests => 11; |
| 21 |
|
21 |
|
| 22 |
use C4::Biblio; |
22 |
use C4::Biblio; |
| 23 |
use Koha::Database; |
23 |
use Koha::Database; |
|
|
24 |
use Koha::Acquisition::Orders; |
| 24 |
|
25 |
|
| 25 |
use t::lib::TestBuilder; |
26 |
use t::lib::TestBuilder; |
| 26 |
use t::lib::Mocks; |
27 |
use t::lib::Mocks; |
|
Lines 490-492
subtest 'suggestions() tests' => sub {
Link Here
|
| 490 |
|
491 |
|
| 491 |
$schema->storage->txn_rollback; |
492 |
$schema->storage->txn_rollback; |
| 492 |
}; |
493 |
}; |
| 493 |
- |
494 |
|
|
|
495 |
subtest 'orders() and active_orders_count() tests' => sub { |
| 496 |
|
| 497 |
plan tests => 4; |
| 498 |
|
| 499 |
$schema->storage->txn_begin; |
| 500 |
|
| 501 |
my $biblio = $builder->build_sample_biblio(); |
| 502 |
|
| 503 |
my $orders = $biblio->orders; |
| 504 |
my $active_orders_count = $biblio->active_orders_count; |
| 505 |
|
| 506 |
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
| 507 |
is( $orders->count, $active_orders_count, '->orders_count returns the count for the resultset' ); |
| 508 |
|
| 509 |
# Add a couple orders |
| 510 |
foreach (1..2) { |
| 511 |
$builder->build_object( |
| 512 |
{ |
| 513 |
class => 'Koha::Acquisition::Orders', |
| 514 |
value => { |
| 515 |
biblionumber => $biblio->biblionumber, |
| 516 |
datecancellationprinted => '2019-12-31' |
| 517 |
} |
| 518 |
} |
| 519 |
); |
| 520 |
} |
| 521 |
|
| 522 |
$builder->build_object( |
| 523 |
{ |
| 524 |
class => 'Koha::Acquisition::Orders', |
| 525 |
value => { |
| 526 |
biblionumber => $biblio->biblionumber, |
| 527 |
datecancellationprinted => undef |
| 528 |
} |
| 529 |
} |
| 530 |
); |
| 531 |
|
| 532 |
$orders = $biblio->orders; |
| 533 |
$active_orders_count = $biblio->active_orders_count; |
| 534 |
|
| 535 |
is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); |
| 536 |
is( $orders->count, $active_orders_count + 2, '->active_orders_count returns the rigt count' ); |
| 537 |
|
| 538 |
$schema->storage->txn_rollback; |
| 539 |
}; |