Lines 37-43
use Koha::Old::Items;
Link Here
|
37 |
use Koha::Recalls; |
37 |
use Koha::Recalls; |
38 |
use Koha::AuthorisedValues; |
38 |
use Koha::AuthorisedValues; |
39 |
|
39 |
|
40 |
use List::MoreUtils qw(all); |
40 |
use List::MoreUtils qw(all any); |
41 |
|
41 |
|
42 |
use t::lib::TestBuilder; |
42 |
use t::lib::TestBuilder; |
43 |
use t::lib::Mocks; |
43 |
use t::lib::Mocks; |
Lines 46-53
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 '_status' => sub { |
49 |
subtest '_status() tests' => sub { |
50 |
plan tests => 12; |
50 |
|
|
|
51 |
plan tests => 15; |
51 |
|
52 |
|
52 |
$schema->storage->txn_begin; |
53 |
$schema->storage->txn_begin; |
53 |
|
54 |
|
Lines 66-72
subtest '_status' => sub {
Link Here
|
66 |
AddIssue( $patron, $onloan_item->barcode, dt_from_string ); |
67 |
AddIssue( $patron, $onloan_item->barcode, dt_from_string ); |
67 |
return $onloan_item; |
68 |
return $onloan_item; |
68 |
}, |
69 |
}, |
69 |
expected_status => 'checked_out', |
70 |
expected_status => ['checked_out'], |
70 |
description => 'Checked out status correctly returned', |
71 |
description => 'Checked out status correctly returned', |
71 |
}, |
72 |
}, |
72 |
{ |
73 |
{ |
Lines 78-91
subtest '_status' => sub {
Link Here
|
78 |
); |
79 |
); |
79 |
return $onsite_item; |
80 |
return $onsite_item; |
80 |
}, |
81 |
}, |
81 |
expected_status => 'local_use', |
82 |
expected_status => ['local_use'], |
82 |
description => 'Local use status correctly returned', |
83 |
description => 'Local use status correctly returned', |
83 |
}, |
84 |
}, |
84 |
{ |
85 |
{ |
85 |
setup => sub { |
86 |
setup => sub { |
86 |
return $item; |
87 |
return $item; |
87 |
}, |
88 |
}, |
88 |
expected_status => 'available', |
89 |
expected_status => ['available'], |
89 |
description => 'Available status correctly returned', |
90 |
description => 'Available status correctly returned', |
90 |
}, |
91 |
}, |
91 |
{ |
92 |
{ |
Lines 93-99
subtest '_status' => sub {
Link Here
|
93 |
$item->itemlost(1)->store(); |
94 |
$item->itemlost(1)->store(); |
94 |
return $item; |
95 |
return $item; |
95 |
}, |
96 |
}, |
96 |
expected_status => 'lost', |
97 |
expected_status => ['lost'], |
97 |
description => 'Lost status correctly returned', |
98 |
description => 'Lost status correctly returned', |
98 |
}, |
99 |
}, |
99 |
{ |
100 |
{ |
Lines 101-107
subtest '_status' => sub {
Link Here
|
101 |
$item->withdrawn(1)->store(); |
102 |
$item->withdrawn(1)->store(); |
102 |
return $item; |
103 |
return $item; |
103 |
}, |
104 |
}, |
104 |
expected_status => qr/lost,withdrawn/, |
105 |
expected_status => [qw(lost withdrawn)], |
105 |
description => 'Lost and withdrawn status correctly returned', |
106 |
description => 'Lost and withdrawn status correctly returned', |
106 |
}, |
107 |
}, |
107 |
{ |
108 |
{ |
Lines 109-115
subtest '_status' => sub {
Link Here
|
109 |
$item->damaged(1)->store(); |
110 |
$item->damaged(1)->store(); |
110 |
return $item; |
111 |
return $item; |
111 |
}, |
112 |
}, |
112 |
expected_status => qr/lost,withdrawn,damaged/, |
113 |
expected_status => [qw(lost withdrawn damaged)], |
113 |
description => 'Lost, withdrawn, and damaged status correctly returned', |
114 |
description => 'Lost, withdrawn, and damaged status correctly returned', |
114 |
}, |
115 |
}, |
115 |
{ |
116 |
{ |
Lines 117-123
subtest '_status' => sub {
Link Here
|
117 |
$item->notforloan(1)->store(); |
118 |
$item->notforloan(1)->store(); |
118 |
return $item; |
119 |
return $item; |
119 |
}, |
120 |
}, |
120 |
expected_status => 'not_for_loan', |
121 |
expected_status => ['not_for_loan'], |
121 |
description => 'Positive not_for_loan status correctly returned', |
122 |
description => 'Positive not_for_loan status correctly returned', |
122 |
}, |
123 |
}, |
123 |
{ |
124 |
{ |
Lines 125-131
subtest '_status' => sub {
Link Here
|
125 |
$item->notforloan(-1)->store(); |
126 |
$item->notforloan(-1)->store(); |
126 |
return $item; |
127 |
return $item; |
127 |
}, |
128 |
}, |
128 |
expected_status => 'not_for_loan', |
129 |
expected_status => ['not_for_loan'], |
129 |
description => 'Negative not_for_loan status correctly returned', |
130 |
description => 'Negative not_for_loan status correctly returned', |
130 |
}, |
131 |
}, |
131 |
{ |
132 |
{ |
Lines 134-140
subtest '_status' => sub {
Link Here
|
134 |
my $notforloan_item = $builder->build_sample_item( { itype => $itemtype->itemtype, } ); |
135 |
my $notforloan_item = $builder->build_sample_item( { itype => $itemtype->itemtype, } ); |
135 |
return $notforloan_item; |
136 |
return $notforloan_item; |
136 |
}, |
137 |
}, |
137 |
expected_status => 'not_for_loan', |
138 |
expected_status => ['not_for_loan'], |
138 |
description => 'Item type not_for_loan status correctly returned', |
139 |
description => 'Item type not_for_loan status correctly returned', |
139 |
}, |
140 |
}, |
140 |
{ |
141 |
{ |
Lines 150-156
subtest '_status' => sub {
Link Here
|
150 |
); |
151 |
); |
151 |
return $onhold_item; |
152 |
return $onhold_item; |
152 |
}, |
153 |
}, |
153 |
expected_status => 'on_hold', |
154 |
expected_status => ['on_hold'], |
154 |
description => 'On hold status correctly returned', |
155 |
description => 'On hold status correctly returned', |
155 |
}, |
156 |
}, |
156 |
{ |
157 |
{ |
Lines 161-167
subtest '_status' => sub {
Link Here
|
161 |
{ biblio => $recalled_item->biblio, item => $recalled_item, patron => $patron } ); |
162 |
{ biblio => $recalled_item->biblio, item => $recalled_item, patron => $patron } ); |
162 |
return $recalled_item; |
163 |
return $recalled_item; |
163 |
}, |
164 |
}, |
164 |
expected_status => 'recalled', |
165 |
expected_status => ['recalled'], |
165 |
description => 'Recalled status correctly returned', |
166 |
description => 'Recalled status correctly returned', |
166 |
}, |
167 |
}, |
167 |
{ |
168 |
{ |
Lines 169-182
subtest '_status' => sub {
Link Here
|
169 |
$item->restricted(1)->store(); |
170 |
$item->restricted(1)->store(); |
170 |
return $item; |
171 |
return $item; |
171 |
}, |
172 |
}, |
172 |
expected_status => 'restricted', |
173 |
expected_status => ['restricted'], |
173 |
description => 'Restricted status correctly returned', |
174 |
description => 'Restricted status correctly returned', |
174 |
}, |
175 |
}, |
175 |
); |
176 |
); |
176 |
|
177 |
|
177 |
foreach my $test_case (@test_cases) { |
178 |
foreach my $test_case (@test_cases) { |
178 |
my $item = $test_case->{setup}->(); |
179 |
my $item = $test_case->{setup}->(); |
179 |
ok( $item->_status() =~ /$test_case->{expected_status}/, $test_case->{description} ); |
180 |
|
|
|
181 |
my $expected_statuses = $test_case->{expected_status}; |
182 |
foreach my $expected_status ( @{$expected_statuses} ) { |
183 |
ok( |
184 |
( any { $expected_status eq $_ } @{ $item->_status() } ), |
185 |
$test_case->{description} . " ($expected_status)" |
186 |
); |
187 |
} |
180 |
} |
188 |
} |
181 |
|
189 |
|
182 |
t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); |
190 |
t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); |
183 |
- |
|
|