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

(-)a/t/db_dependent/ILSDI_Services.t (-37 / +15 lines)
Lines 553-591 subtest 'Holds test with start_date and end_date' => sub { Link Here
553
553
554
    $schema->storage->txn_begin;
554
    $schema->storage->txn_begin;
555
555
556
    my $pickup_branch = $builder->build(
556
    my $pickup_library = $builder->build_object(
557
        {
557
        {
558
            source => 'Branch',
558
            class  => 'Koha::Libraries',
559
            value  => {
559
            value  => {
560
                pickup_location => 1,
560
                pickup_location => 1,
561
            }
561
            }
562
        }
562
        }
563
    );
563
    );
564
564
565
    my $patron = $builder->build({
565
    my $patron = $builder->build_object({
566
        source => 'Borrower',
566
        class => 'Koha::Patrons',
567
    });
568
569
    my $biblio = $builder->build({
570
        source => 'Biblio',
571
    });
572
573
    my $biblioitems = $builder->build({
574
        source => 'Biblioitem',
575
        value => {
576
            biblionumber => $biblio->{biblionumber},
577
        }
578
    });
567
    });
579
568
580
    my $item = $builder->build({
569
    my $item = $builder->build_sample_item({ library => $pickup_library->branchcode });
581
        source => 'Item',
582
        value => {
583
            homebranch => $pickup_branch->{branchcode},
584
            holdingbranch => $pickup_branch->{branchcode},
585
            biblionumber => $biblio->{biblionumber},
586
            damaged => 0,
587
        }
588
    });
589
570
590
    Koha::CirculationRules->set_rule(
571
    Koha::CirculationRules->set_rule(
591
        {
572
        {
Lines 598-625 subtest 'Holds test with start_date and end_date' => sub { Link Here
598
    );
579
    );
599
580
600
    my $query = new CGI;
581
    my $query = new CGI;
601
    $query->param( 'pickup_location', $pickup_branch->{branchcode} );
582
    $query->param( 'pickup_location', $pickup_library->branchcode );
602
    $query->param( 'patron_id', $patron->{borrowernumber});
583
    $query->param( 'patron_id', $patron->borrowernumber);
603
    $query->param( 'bib_id', $biblio->{biblionumber});
584
    $query->param( 'bib_id', $item->biblionumber);
604
    $query->param( 'item_id', $item->{itemnumber});
585
    $query->param( 'item_id', $item->itemnumber);
605
    $query->param( 'start_date', '2020-03-20');
586
    $query->param( 'start_date', '2020-03-20');
606
    $query->param( 'expiry_date', '2020-04-22');
587
    $query->param( 'expiry_date', '2020-04-22');
607
588
608
    my $reply = C4::ILSDI::Services::HoldItem( $query );
589
    my $reply = C4::ILSDI::Services::HoldItem( $query );
609
    is ($reply->{pickup_location}, $pickup_branch->{branchname}, "Item hold with date parameters was placed");
590
    is ($reply->{pickup_location}, $pickup_library->branchname, "Item hold with date parameters was placed");
610
    my $hold = Koha::Holds->search({ biblionumber => $biblio->{biblionumber}})->next();
591
    my $hold = Koha::Holds->search({ biblionumber => $item->biblionumber})->next();
611
    use Data::Dumper;
592
    is( $hold->biblionumber, $item->biblionumber, "correct biblionumber");
612
    print Dumper($hold);
613
    is( $hold->biblionumber, $biblio->{biblionumber}, "correct biblionumber");
614
    is( $hold->reservedate, '2020-03-20', "Item hold has correct start date" );
593
    is( $hold->reservedate, '2020-03-20', "Item hold has correct start date" );
615
    is( $hold->expirationdate, '2020-04-22', "Item hold has correct end date" );
594
    is( $hold->expirationdate, '2020-04-22', "Item hold has correct end date" );
616
595
617
    $hold->delete();
596
    $hold->delete();
618
597
619
    $reply = C4::ILSDI::Services::HoldTitle( $query );
598
    $reply = C4::ILSDI::Services::HoldTitle( $query );
620
    is ($reply->{pickup_location}, $pickup_branch->{branchname}, "Record hold with date parameters was placed");
599
    is ($reply->{pickup_location}, $pickup_library->branchname, "Record hold with date parameters was placed");
621
    $hold = Koha::Holds->search({ biblionumber => $biblio->{biblionumber}})->next();
600
    $hold = Koha::Holds->search({ biblionumber => $item->biblionumber})->next();
622
    is( $hold->biblionumber, $biblio->{biblionumber}, "correct biblionumber");
601
    is( $hold->biblionumber, $item->biblionumber, "correct biblionumber");
623
    is( $hold->reservedate, '2020-03-20', "Record hold has correct start date" );
602
    is( $hold->reservedate, '2020-03-20', "Record hold has correct start date" );
624
    is( $hold->expirationdate, '2020-04-22', "Record hold has correct end date" );
603
    is( $hold->expirationdate, '2020-04-22', "Record hold has correct end date" );
625
604
626
- 

Return to bug 23531