|
Lines 131-141
AddReturn( $item1->{barcode} );
Link Here
|
| 131 |
my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|); |
131 |
my $sth_delete_rules = $dbh->prepare(q|DELETE FROM default_circ_rules|); |
| 132 |
my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', NULL, NULL, ?, 'any', 'homebranch');|); |
132 |
my $sth_insert_rule = $dbh->prepare(q|INSERT INTO default_circ_rules(singleton, maxissueqty, maxonsiteissueqty, holdallowed, hold_fulfillment_policy, returnbranch) VALUES ('singleton', NULL, NULL, ?, 'any', 'homebranch');|); |
| 133 |
|
133 |
|
| 134 |
subtest 'Item is checked out from the same library' => sub { |
134 |
subtest 'Item is available at a different library' => sub { |
| 135 |
plan tests => 4; |
135 |
plan tests => 4; |
| 136 |
|
136 |
|
| 137 |
Koha::Items->find( $item1->{itemnumber} )->set({homebranch => $library_B, holdingbranch => $library_B })->store; |
137 |
Koha::Items->find( $item1->{itemnumber} )->set({homebranch => $library_B, holdingbranch => $library_B })->store; |
| 138 |
$item1 = GetItem( $itemnumber1 ); |
138 |
$item1 = GetItem( $itemnumber1 ); |
|
|
139 |
#Scenario is: |
| 140 |
#One shelf holds is 'If all unavailable'/2 |
| 141 |
#Item 1 homebranch library B is available |
| 142 |
#Item 2 homebranch library A is checked out |
| 143 |
#Borrower1 is from library A |
| 144 |
#CircControl has no effect - same rule for all branches as set at line 96 |
| 145 |
#FIXME: ReservesControlBranch is not checked in these subs we are testing |
| 139 |
|
146 |
|
| 140 |
{ |
147 |
{ |
| 141 |
$sth_delete_rules->execute; |
148 |
$sth_delete_rules->execute; |
|
Lines 143-153
AddReturn( $item1->{barcode} );
Link Here
|
| 143 |
|
150 |
|
| 144 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
151 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 145 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
152 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 146 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library => the hold is allowed at item level" ); |
153 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" ); |
| 147 |
|
154 |
|
| 148 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
155 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
| 149 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
156 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 150 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at the same library => the hold is allowed at item level" ); |
157 |
is( $is, 1, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at different library, not holdable = none available => the hold is allowed at item level" ); |
| 151 |
} |
158 |
} |
| 152 |
|
159 |
|
| 153 |
{ |
160 |
{ |
|
Lines 156-174
AddReturn( $item1->{barcode} );
Link Here
|
| 156 |
|
163 |
|
| 157 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
164 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 158 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
165 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 159 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library => the hold is allowed at item level" ); |
166 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" ); |
| 160 |
|
167 |
|
| 161 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
168 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
| 162 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
169 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 163 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the same library => the hold is allowed at item level" ); |
170 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the diff library, holdable = 1 available => the hold is not allowed at item level" ); |
| 164 |
} |
171 |
} |
| 165 |
}; |
172 |
}; |
| 166 |
|
173 |
|
| 167 |
subtest 'Item is checked out from the another library' => sub { |
174 |
subtest 'Item is available at the same library' => sub { |
| 168 |
plan tests => 4; |
175 |
plan tests => 4; |
| 169 |
|
176 |
|
| 170 |
Koha::Items->find( $item1->{itemnumber} )->set({homebranch => $library_A, holdingbranch => $library_A })->store; |
177 |
Koha::Items->find( $item1->{itemnumber} )->set({homebranch => $library_A, holdingbranch => $library_A })->store; |
| 171 |
$item1 = GetItem( $itemnumber1 ); |
178 |
$item1 = GetItem( $itemnumber1 ); |
|
|
179 |
#Scenario is: |
| 180 |
#One shelf holds is 'If all unavailable'/2 |
| 181 |
#Item 1 homebranch library A is available |
| 182 |
#Item 2 homebranch library A is checked out |
| 183 |
#Borrower1 is from library A |
| 184 |
#CircControl has no effect - same rule for all branches as set at line 96 |
| 185 |
#ReservesControlBranch is not checked in these subs we are testing? |
| 172 |
|
186 |
|
| 173 |
{ |
187 |
{ |
| 174 |
$sth_delete_rules->execute; |
188 |
$sth_delete_rules->execute; |
|
Lines 176-186
AddReturn( $item1->{barcode} );
Link Here
|
| 176 |
|
190 |
|
| 177 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
191 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 178 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
192 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 179 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library => the hold is allowed at item level" ); |
193 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library, holdable = 1 available => the hold is not allowed at item level" ); |
| 180 |
|
194 |
|
| 181 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
195 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
| 182 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
196 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 183 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at the same library => the hold is allowed at item level" ); |
197 |
is( $is, 0, "Hold allowed from home library + ReservesControlBranch=PatronLibrary, One item is available at the same library, holdable = 1 available => the hold is not allowed at item level" ); |
| 184 |
} |
198 |
} |
| 185 |
|
199 |
|
| 186 |
{ |
200 |
{ |
|
Lines 189-199
AddReturn( $item1->{barcode} );
Link Here
|
| 189 |
|
203 |
|
| 190 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
204 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
| 191 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
205 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 192 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library => the hold is allowed at item level" ); |
206 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=ItemHomeLibrary, One item is available at the same library, holdable = 1 available => the hold is not allowed at item level" ); |
| 193 |
|
207 |
|
| 194 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
208 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
| 195 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
209 |
$is = IsAvailableForItemLevelRequest( $item1, $borrower1); |
| 196 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the same library => the hold is allowed at item level" ); |
210 |
is( $is, 0, "Hold allowed from any library + ReservesControlBranch=PatronLibrary, One item is available at the same library, holdable = 1 available => the hold is not allowed at item level" ); |
| 197 |
} |
211 |
} |
| 198 |
}; |
212 |
}; |
| 199 |
}; |
213 |
}; |
| 200 |
- |
|
|