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

(-)a/t/db_dependent/Koha/Item.t (-3 / +49 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use utf8;
21
use utf8;
22
22
23
use Test::More tests => 38;
23
use Test::More tests => 39;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
26
use Test::Warn;
26
use Test::Warn;
Lines 45-56 use t::lib::Dates; Link Here
45
my $schema  = Koha::Database->new->schema;
45
my $schema  = Koha::Database->new->schema;
46
my $builder = t::lib::TestBuilder->new;
46
my $builder = t::lib::TestBuilder->new;
47
47
48
subtest 'store PreventWithDrawingItemsStatus' => sub {
49
    plan tests => 2;
50
    $schema->storage->txn_begin;
51
52
    t::lib::Mocks::mock_preference( 'PreventWithDrawingItemsStatus', 'intransit,checkedout' );
53
    my $library_1 = $builder->build( { source => 'Branch' } );
54
    my $library_2 = $builder->build( { source => 'Branch' } );
55
56
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
57
    t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } );
58
59
    my $item = $builder->build_sample_item({
60
            withdrawn => 0,
61
    });
62
63
    #Check item out
64
    C4::Circulation::AddIssue( $patron, $item->barcode );
65
66
    throws_ok { $item->withdrawn('1')->store }
67
        'Koha::Exceptions::Item::Transfer::OnLoan',
68
        'Exception thrown when trying to withdraw checked-out item';
69
70
    my $item_2 = $builder->build_sample_item({
71
            withdrawn => 0,
72
    });
73
74
    #set in_transit
75
    my $transfer_1 = $builder->build_object(
76
        {
77
            class => 'Koha::Item::Transfers',
78
            value => {
79
                itemnumber    => $item_2->itemnumber,
80
                frombranch    => $library_1->{branchcode},
81
                tobranch      => $library_2->{branchcode},
82
                datesent => '1999-12-31',
83
            }
84
        }
85
    );
86
87
    throws_ok { $item_2->withdrawn('1')->store }
88
        'Koha::Exceptions::Item::Transfer::InTransit',
89
        'Exception thrown when trying to withdraw item in transit';
90
91
    t::lib::Mocks::mock_preference( 'PreventWithDrawingItemsStatus', '' );
92
93
    $schema->storage->txn_rollback;
94
};
95
48
subtest 'z3950_status' => sub {
96
subtest 'z3950_status' => sub {
49
    plan tests => 9;
97
    plan tests => 9;
50
98
51
    $schema->storage->txn_begin;
99
    $schema->storage->txn_begin;
52
    t::lib::Mocks::mock_preference( 'z3950Status', '' );
100
    t::lib::Mocks::mock_preference( 'z3950Status', '' );
53
54
    my $itemtype = $builder->build_object( { class => "Koha::ItemTypes" } );
101
    my $itemtype = $builder->build_object( { class => "Koha::ItemTypes" } );
55
    my $item     = $builder->build_sample_item(
102
    my $item     = $builder->build_sample_item(
56
        {
103
        {
57
- 

Return to bug 23010