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

(-)a/t/db_dependent/Koha/ILL/Requests.t (-2 / +70 lines)
Lines 1572-1578 subtest 'Custom statuses' => sub { Link Here
1572
1572
1573
subtest 'Checking in hook' => sub {
1573
subtest 'Checking in hook' => sub {
1574
1574
1575
    plan tests => 2;
1575
    plan tests => 6;
1576
1576
1577
    $schema->storage->txn_begin;
1577
    $schema->storage->txn_begin;
1578
1578
Lines 1626-1631 subtest 'Checking in hook' => sub { Link Here
1626
    $illrq->discard_changes;
1626
    $illrq->discard_changes;
1627
    is( $illrq->status, 'RET' );
1627
    is( $illrq->status, 'RET' );
1628
1628
1629
    my $request_for_checkout_out = $builder->build_sample_ill_request();
1630
    $builder->build(
1631
        {
1632
            source => 'Illrequestattribute',
1633
            value  => { illrequest_id => $request_for_checkout_out->illrequest_id, type => 'type', value => 'book' }
1634
        }
1635
    );
1636
1637
    my $newly_created_biblio = Koha::Biblios->find( { biblionumber => $request_for_checkout_out->biblio_id } );
1638
    is( $newly_created_biblio->items->count, 0, 'Biblio created without items' );
1639
1640
    my $itemtype = $builder->build_object(
1641
        {
1642
            class => 'Koha::ItemTypes',
1643
            value => {
1644
                notforloan                  => 0,
1645
                rentalcharge                => 0,
1646
                rentalcharge_daily          => 1,
1647
                rentalcharge_daily_calendar => 0
1648
            }
1649
        }
1650
    )->store;
1651
1652
    my $check_out = $request_for_checkout_out->check_out(
1653
        {
1654
            'branchcode'    => $request_for_checkout_out->branchcode,
1655
            'item_type'     => $itemtype->itemtype,
1656
            'illrequest_id' => $request_for_checkout_out->illrequest_id,
1657
            'stage'         => 'form',
1658
        }
1659
    );
1660
1661
    is( $newly_created_biblio->items->count, 1,     'A new item was created after checking out' );
1662
    is( $check_out->{value}->{errors},       undef, 'No errors. Check-out was successful' );
1663
1664
    # Test if biblio already has an item with no barcode
1665
1666
    my $another_checkout_out_request = $builder->build_sample_ill_request();
1667
    $builder->build(
1668
        {
1669
            source => 'Illrequestattribute',
1670
            value  => { illrequest_id => $another_checkout_out_request->illrequest_id, type => 'type', value => 'book' }
1671
        }
1672
    );
1673
    my $another_newly_created_biblio =
1674
        Koha::Biblios->find( { biblionumber => $another_checkout_out_request->biblio_id } );
1675
1676
    Koha::Item->new(
1677
        {
1678
            biblionumber  => $another_newly_created_biblio->biblionumber,
1679
            homebranch    => $another_checkout_out_request->branchcode,
1680
            holdingbranch => $another_checkout_out_request->branchcode,
1681
            barcode       => ''
1682
        }
1683
    )->store;
1684
1685
    my $another_check_out = $another_checkout_out_request->check_out(
1686
        {
1687
            'branchcode'    => $another_checkout_out_request->branchcode,
1688
            'item_type'     => $itemtype->itemtype,
1689
            'illrequest_id' => $another_checkout_out_request->illrequest_id,
1690
            'stage'         => 'form',
1691
        }
1692
    );
1693
    is(
1694
        $another_check_out->{value}->{check_out_errors}->{error}->{UNKNOWN_BARCODE}, 1,
1695
        'Barcode related error is set because existing item does not have a barcode'
1696
    );
1697
1629
    $schema->storage->txn_rollback;
1698
    $schema->storage->txn_rollback;
1630
};
1699
};
1631
1700
1632
- 

Return to bug 38505