|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
| 23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
| 24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
| 25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
|
Lines 198-200
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
Link Here
|
| 198 |
$schema->storage->txn_rollback; |
198 |
$schema->storage->txn_rollback; |
| 199 |
}; |
199 |
}; |
| 200 |
|
200 |
|
| 201 |
- |
201 |
subtest 'Holds test' => sub { |
|
|
202 |
|
| 203 |
plan tests => 3; |
| 204 |
|
| 205 |
$schema->storage->txn_begin; |
| 206 |
|
| 207 |
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); |
| 208 |
|
| 209 |
my $patron = $builder->build({ |
| 210 |
source => 'Borrower', |
| 211 |
}); |
| 212 |
|
| 213 |
my $biblio = $builder->build({ |
| 214 |
source => 'Biblio', |
| 215 |
}); |
| 216 |
|
| 217 |
my $biblioitems = $builder->build({ |
| 218 |
source => 'Biblioitem', |
| 219 |
value => { |
| 220 |
biblionumber => $biblio->{biblionumber}, |
| 221 |
} |
| 222 |
}); |
| 223 |
|
| 224 |
my $item = $builder->build({ |
| 225 |
source => 'Item', |
| 226 |
value => { |
| 227 |
biblionumber => $biblio->{biblionumber}, |
| 228 |
damaged => 1 |
| 229 |
} |
| 230 |
}); |
| 231 |
|
| 232 |
my $query = new CGI; |
| 233 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
| 234 |
$query->param( 'bib_id', $biblio->{biblionumber}); |
| 235 |
|
| 236 |
my $reply = C4::ILSDI::Services::HoldTitle( $query ); |
| 237 |
is( $reply->{code}, 'damaged', "Item damaged" ); |
| 238 |
|
| 239 |
my $item_o = Koha::Items->find($item->{itemnumber}); |
| 240 |
$item_o->damaged(0)->store; |
| 241 |
|
| 242 |
my $hold = $builder->build({ |
| 243 |
source => 'Reserve', |
| 244 |
value => { |
| 245 |
borrowernumber => $patron->{borrowernumber}, |
| 246 |
biblionumber => $biblio->{biblionumber}, |
| 247 |
itemnumber => $item->{itemnumber} |
| 248 |
} |
| 249 |
}); |
| 250 |
|
| 251 |
$reply = C4::ILSDI::Services::HoldTitle( $query ); |
| 252 |
is( $reply->{code}, 'itemAlreadyOnHold', "Item already on hold" ); |
| 253 |
|
| 254 |
my $biblio2 = $builder->build({ |
| 255 |
source => 'Biblio', |
| 256 |
}); |
| 257 |
|
| 258 |
my $biblioitems2 = $builder->build({ |
| 259 |
source => 'Biblioitem', |
| 260 |
value => { |
| 261 |
biblionumber => $biblio2->{biblionumber}, |
| 262 |
} |
| 263 |
}); |
| 264 |
|
| 265 |
my $item2 = $builder->build({ |
| 266 |
source => 'Item', |
| 267 |
value => { |
| 268 |
biblionumber => $biblio2->{biblionumber}, |
| 269 |
damaged => 0 |
| 270 |
} |
| 271 |
}); |
| 272 |
|
| 273 |
t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); |
| 274 |
my $issuingrule = $builder->build({ |
| 275 |
source => 'Issuingrule', |
| 276 |
value => { |
| 277 |
categorycode => $patron->{categorycode}, |
| 278 |
itemtype => $item2->{itype}, |
| 279 |
branchcode => $patron->{branchcode}, |
| 280 |
reservesallowed => 0, |
| 281 |
} |
| 282 |
}); |
| 283 |
|
| 284 |
$query = new CGI; |
| 285 |
$query->param( 'patron_id', $patron->{borrowernumber}); |
| 286 |
$query->param( 'bib_id', $biblio2->{biblionumber}); |
| 287 |
$query->param( 'item_id', $item2->{itemnumber}); |
| 288 |
|
| 289 |
$reply = C4::ILSDI::Services::HoldItem( $query ); |
| 290 |
is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); |
| 291 |
|
| 292 |
$schema->storage->txn_rollback; |
| 293 |
}; |