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 |
{ |
61 |
withdrawn => 0, |
62 |
} |
63 |
); |
64 |
|
65 |
#Check item out |
66 |
C4::Circulation::AddIssue( $patron, $item->barcode ); |
67 |
|
68 |
throws_ok { $item->withdrawn('1')->store } |
69 |
'Koha::Exceptions::Item::Transfer::OnLoan', |
70 |
'Exception thrown when trying to withdraw checked-out item'; |
71 |
|
72 |
my $item_2 = $builder->build_sample_item( |
73 |
{ |
74 |
withdrawn => 0, |
75 |
} |
76 |
); |
77 |
|
78 |
#set in_transit |
79 |
my $transfer_1 = $builder->build_object( |
80 |
{ |
81 |
class => 'Koha::Item::Transfers', |
82 |
value => { |
83 |
itemnumber => $item_2->itemnumber, |
84 |
frombranch => $library_1->{branchcode}, |
85 |
tobranch => $library_2->{branchcode}, |
86 |
datesent => '1999-12-31', |
87 |
} |
88 |
} |
89 |
); |
90 |
|
91 |
throws_ok { $item_2->withdrawn('1')->store } |
92 |
'Koha::Exceptions::Item::Transfer::InTransit', |
93 |
'Exception thrown when trying to withdraw item in transit'; |
94 |
|
95 |
t::lib::Mocks::mock_preference( 'PreventWithDrawingItemsStatus', '' ); |
96 |
|
97 |
$schema->storage->txn_rollback; |
98 |
}; |
99 |
|
48 |
subtest 'z3950_status' => sub { |
100 |
subtest 'z3950_status' => sub { |
49 |
plan tests => 9; |
101 |
plan tests => 9; |
50 |
|
102 |
|
51 |
$schema->storage->txn_begin; |
103 |
$schema->storage->txn_begin; |
52 |
t::lib::Mocks::mock_preference( 'z3950Status', '' ); |
104 |
t::lib::Mocks::mock_preference( 'z3950Status', '' ); |
53 |
|
|
|
54 |
my $itemtype = $builder->build_object( { class => "Koha::ItemTypes" } ); |
105 |
my $itemtype = $builder->build_object( { class => "Koha::ItemTypes" } ); |
55 |
my $item = $builder->build_sample_item( |
106 |
my $item = $builder->build_sample_item( |
56 |
{ |
107 |
{ |
57 |
- |
|
|