Lines 29-35
use Koha::Item;
Link Here
|
29 |
use Koha::DateUtils qw( dt_from_string ); |
29 |
use Koha::DateUtils qw( dt_from_string ); |
30 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
31 |
|
31 |
|
32 |
use Test::More tests => 35; |
32 |
use Test::More tests => 36; |
33 |
use Test::Exception; |
33 |
use Test::Exception; |
34 |
use Test::Warn; |
34 |
use Test::Warn; |
35 |
|
35 |
|
Lines 386-388
subtest 'suspend() tests' => sub {
Link Here
|
386 |
|
386 |
|
387 |
$schema->storage->txn_rollback; |
387 |
$schema->storage->txn_rollback; |
388 |
}; |
388 |
}; |
389 |
- |
389 |
|
|
|
390 |
subtest 'can_change_branch_opac() tests' => sub { |
391 |
|
392 |
plan tests => 8; |
393 |
|
394 |
$schema->storage->txn_begin; |
395 |
|
396 |
my $hold = $builder->build_object( |
397 |
{ class => 'Koha::Holds', |
398 |
value => { found => undef, suspend => 0, suspend_until => undef, waitingdate => undef } |
399 |
} |
400 |
); |
401 |
|
402 |
t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', '' ); |
403 |
$hold->found(undef); |
404 |
is( $hold->can_change_branch_opac, 0, "Pending hold pickup can't be changed (No change allowed)" ); |
405 |
|
406 |
$hold->found('T'); |
407 |
is( $hold->can_change_branch_opac, 0, "In transit hold pickup can't be changed (No change allowed)" ); |
408 |
|
409 |
$hold->found('W'); |
410 |
is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (No change allowed)" ); |
411 |
|
412 |
$hold->found(undef); |
413 |
$dt = dt_from_string(); |
414 |
|
415 |
$hold->suspend_hold( $dt ); |
416 |
is( $hold->can_change_branch_opac, 0, "Suspended hold pickup can't be changed (No change allowed)" ); |
417 |
$hold->resume(); |
418 |
|
419 |
t::lib::Mocks::mock_preference( 'OPACAllowUserToChangeBranch', 'pending,intransit,suspended' ); |
420 |
$hold->found(undef); |
421 |
is( $hold->can_change_branch_opac, 1, "Pending hold pickup can be changed (pending,intransit,suspended allowed)" ); |
422 |
|
423 |
$hold->found('T'); |
424 |
is( $hold->can_change_branch_opac, 1, "In transit hold pickup can be changed (pending,intransit,suspended allowed)" ); |
425 |
|
426 |
$hold->found('W'); |
427 |
is( $hold->can_change_branch_opac, 0, "Waiting hold pickup can't be changed (pending,intransit,suspended allowed)" ); |
428 |
|
429 |
$hold->found(undef); |
430 |
$dt = dt_from_string(); |
431 |
$hold->suspend_hold( $dt ); |
432 |
is( $hold->can_change_branch_opac, 1, "Suspended hold pickup can be changed (pending,intransit,suspended allowed)" ); |
433 |
$hold->resume(); |
434 |
|
435 |
|
436 |
$schema->storage->txn_rollback; |
437 |
|
438 |
}; |