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

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

Return to bug 23010