View | Details | Raw Unified | Return to bug 24430
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Biblio.t (-2 / +48 lines)
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 494-496 subtest 'suggestions() tests' => sub { Link Here
494
495
495
    $schema->storage->txn_rollback;
496
    $schema->storage->txn_rollback;
496
};
497
};
497
- 
498
499
subtest 'orders() and active_orders_count() tests' => sub {
500
501
    plan tests => 4;
502
503
    $schema->storage->txn_begin;
504
505
    my $biblio = $builder->build_sample_biblio();
506
507
    my $orders = $biblio->orders;
508
    my $active_orders_count = $biblio->active_orders_count;
509
510
    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' );
512
513
    # Add a couple orders
514
    foreach (1..2) {
515
        $builder->build_object(
516
            {
517
                class => 'Koha::Acquisition::Orders',
518
                value => {
519
                    biblionumber => $biblio->biblionumber,
520
                    datecancellationprinted => '2019-12-31'
521
                }
522
            }
523
        );
524
    }
525
526
    $builder->build_object(
527
        {
528
            class => 'Koha::Acquisition::Orders',
529
            value => {
530
                biblionumber => $biblio->biblionumber,
531
                datecancellationprinted => undef
532
            }
533
        }
534
    );
535
536
    $orders = $biblio->orders;
537
    $active_orders_count = $biblio->active_orders_count;
538
539
    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' );
541
542
    $schema->storage->txn_rollback;
543
};

Return to bug 24430