|
Lines 21-27
Link Here
|
| 21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 22 |
|
22 |
|
| 23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
| 24 |
use Test::More tests => 15; |
24 |
use Test::More tests => 16; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockObject; |
26 |
use Test::MockObject; |
| 27 |
use Test::MockModule; |
27 |
use Test::MockModule; |
|
Lines 31-37
use t::lib::Mocks;
Link Here
|
| 31 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
| 32 |
|
32 |
|
| 33 |
use C4::Reserves qw( AddReserve ); |
33 |
use C4::Reserves qw( AddReserve ); |
| 34 |
use C4::Circulation qw( AddReturn ); |
34 |
use C4::Circulation qw( AddIssue AddReturn ); |
| 35 |
use Koha::Database; |
35 |
use Koha::Database; |
| 36 |
use Koha::AuthUtils qw(hash_password); |
36 |
use Koha::AuthUtils qw(hash_password); |
| 37 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
37 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
|
Lines 237-242
subtest 'Lastseen response' => sub {
Link Here
|
| 237 |
|
237 |
|
| 238 |
}; |
238 |
}; |
| 239 |
|
239 |
|
|
|
240 |
subtest "Test patron_status_string" => sub { |
| 241 |
my $schema = Koha::Database->new->schema; |
| 242 |
$schema->storage->txn_begin; |
| 243 |
|
| 244 |
plan tests => 9; |
| 245 |
|
| 246 |
my $builder = t::lib::TestBuilder->new(); |
| 247 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 248 |
my $patron = $builder->build({ |
| 249 |
source => 'Borrower', |
| 250 |
value => { |
| 251 |
branchcode => $branchcode, |
| 252 |
}, |
| 253 |
}); |
| 254 |
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber} ); |
| 255 |
|
| 256 |
t::lib::Mocks::mock_userenv({ branchcode => $branchcode }); |
| 257 |
|
| 258 |
my $item1 = $builder->build_sample_item( |
| 259 |
{ |
| 260 |
damaged => 0, |
| 261 |
withdrawn => 0, |
| 262 |
itemlost => 0, |
| 263 |
restricted => 0, |
| 264 |
homebranch => $branchcode, |
| 265 |
holdingbranch => $branchcode, |
| 266 |
permanent_location => "PERMANENT_LOCATION" |
| 267 |
} |
| 268 |
); |
| 269 |
AddIssue( $patron, $item1->barcode ); |
| 270 |
|
| 271 |
my $item2 = $builder->build_sample_item( |
| 272 |
{ |
| 273 |
damaged => 0, |
| 274 |
withdrawn => 0, |
| 275 |
itemlost => 0, |
| 276 |
restricted => 0, |
| 277 |
homebranch => $branchcode, |
| 278 |
holdingbranch => $branchcode, |
| 279 |
permanent_location => "PERMANENT_LOCATION" |
| 280 |
} |
| 281 |
); |
| 282 |
AddIssue( $patron, $item2->barcode ); |
| 283 |
|
| 284 |
is( Koha::Checkouts->search({ borrowernumber => $patron->{borrowernumber} })->count, 2, "Found 2 checkouts for this patron" ); |
| 285 |
|
| 286 |
$item1->itemlost(1)->store(); |
| 287 |
$item2->itemlost(2)->store(); |
| 288 |
|
| 289 |
is( Koha::Checkouts->search({ borrowernumber => $patron->{borrowernumber}, 'itemlost' => { '>', 0 } }, { join => 'item'} )->count, 2, "Found 2 lost checkouts for this patron" ); |
| 290 |
|
| 291 |
my $server->{account}->{lost_block_checkout} = undef; |
| 292 |
my $patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 293 |
is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 0 does not block checkouts with 2 lost checkouts" );; |
| 294 |
|
| 295 |
$server->{account}->{lost_block_checkout} = 0; |
| 296 |
$patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 297 |
is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 0 does not block checkouts with 2 lost checkouts" );; |
| 298 |
|
| 299 |
$server->{account}->{lost_block_checkout} = 1; |
| 300 |
$patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 301 |
is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 1 does block checkouts with 2 lost checkouts" );; |
| 302 |
|
| 303 |
$server->{account}->{lost_block_checkout} = 2; |
| 304 |
$patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 305 |
is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 2 does block checkouts with 2 lost checkouts" );; |
| 306 |
|
| 307 |
$server->{account}->{lost_block_checkout} = 3; |
| 308 |
$patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 309 |
is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 3 does not block checkouts with 2 lost checkouts" );; |
| 310 |
|
| 311 |
$server->{account}->{lost_block_checkout} = 2; |
| 312 |
$server->{account}->{lost_block_checkout_value} = 2; |
| 313 |
$patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 314 |
is( substr($patron_status_string, 9, 1), q{ }, "lost_block_checkout = 2, lost_block_checkout_value = 2 does not block checkouts with 2 lost checkouts where only 1 has itemlost = 2" ); |
| 315 |
|
| 316 |
$server->{account}->{lost_block_checkout} = 1; |
| 317 |
$server->{account}->{lost_block_checkout_value} = 2; |
| 318 |
$patron_status_string = C4::SIP::Sip::MsgType::patron_status_string( $sip_patron, $server ); |
| 319 |
is( substr($patron_status_string, 9, 1), q{Y}, "lost_block_checkout = 2, lost_block_checkout_value = 2 does block checkouts with 2 lost checkouts where only 1 has itemlost = 2" ); |
| 320 |
|
| 321 |
$schema->storage->txn_rollback; |
| 322 |
}; |
| 323 |
|
| 240 |
subtest "Test build_additional_item_fields_string" => sub { |
324 |
subtest "Test build_additional_item_fields_string" => sub { |
| 241 |
my $schema = Koha::Database->new->schema; |
325 |
my $schema = Koha::Database->new->schema; |
| 242 |
$schema->storage->txn_begin; |
326 |
$schema->storage->txn_begin; |
| 243 |
- |
|
|