Bug 31391: Implement UseRecalls choices in tests

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Aleisha Amohia 2026-06-16 00:26:43 +00:00 committed by Pedro Amorim
parent 6091466f51
commit b9b80b9471
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
7 changed files with 17 additions and 17 deletions

View File

@ -1911,7 +1911,7 @@ subtest "CanBookBeRenewed tests" => sub {
t::lib::Mocks::mock_preference( 'FineNoRenewals', 0 ); t::lib::Mocks::mock_preference( 'FineNoRenewals', 0 );
# Recalls # Recalls
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
Koha::CirculationRules->set_rules( Koha::CirculationRules->set_rules(
{ {
categorycode => undef, categorycode => undef,
@ -2877,7 +2877,7 @@ subtest 'AddIssue & AllowReturnToBranch' => sub {
subtest 'AddIssue | recalls' => sub { subtest 'AddIssue | recalls' => sub {
plan tests => 3; plan tests => 3;
t::lib::Mocks::mock_preference( "UseRecalls", 1 ); t::lib::Mocks::mock_preference( "UseRecalls", 'opac' );
t::lib::Mocks::mock_preference( "item-level_itypes", 1 ); t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } );
my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } );
@ -5691,7 +5691,7 @@ subtest 'CanBookBeIssued | notforloan' => sub {
subtest 'CanBookBeIssued | recalls' => sub { subtest 'CanBookBeIssued | recalls' => sub {
plan tests => 3; plan tests => 3;
t::lib::Mocks::mock_preference( "UseRecalls", 1 ); t::lib::Mocks::mock_preference( "UseRecalls", 'opac' );
t::lib::Mocks::mock_preference( "item-level_itypes", 1 ); t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } );
my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } );
@ -5900,7 +5900,7 @@ subtest 'AddReturn should clear items.onloan for unissued items' => sub {
subtest 'AddReturn | recalls' => sub { subtest 'AddReturn | recalls' => sub {
plan tests => 3; plan tests => 3;
t::lib::Mocks::mock_preference( "UseRecalls", 1 ); t::lib::Mocks::mock_preference( "UseRecalls", 'opac' );
t::lib::Mocks::mock_preference( "item-level_itypes", 1 ); t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } );
my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } );

View File

@ -168,7 +168,7 @@ subtest 'transfer already at destination' => sub {
is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info" ); is( $messages->{ResFound}->{itemnumber}, $item->itemnumber, "We got the reserve info" );
# recalls # recalls
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
my $recall = Koha::Recall->new( my $recall = Koha::Recall->new(
{ {
biblio_id => $item->biblionumber, biblio_id => $item->biblionumber,

View File

@ -1871,10 +1871,10 @@ subtest 'Recalls tests' => sub {
is( $recalls->count, 3, 'Correctly get number of recalls for biblio' ); is( $recalls->count, 3, 'Correctly get number of recalls for biblio' );
is( $recalls->filter_by_current->count, 1, 'Correctly get number of active recalls for biblio' ); is( $recalls->filter_by_current->count, 1, 'Correctly get number of active recalls for biblio' );
t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); t::lib::Mocks::mock_preference( "UseRecalls", "off" );
is( $biblio->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall with UseRecalls disabled" ); is( $biblio->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall with UseRecalls disabled" );
t::lib::Mocks::mock_preference( "UseRecalls", 1 ); t::lib::Mocks::mock_preference( "UseRecalls", "opac" );
$item1->update( { notforloan => 1 } ); $item1->update( { notforloan => 1 } );
is( $biblio->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall with no available items" ); is( $biblio->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall with no available items" );

View File

@ -57,7 +57,7 @@ subtest '_status() tests' => sub {
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); my $library = $builder->build_object( { class => 'Koha::Libraries' } );
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
@ -188,7 +188,7 @@ subtest '_status() tests' => sub {
} }
} }
t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'off' );
$schema->storage->txn_rollback; $schema->storage->txn_rollback;
}; };
@ -2994,7 +2994,7 @@ subtest 'Recalls tests' => sub {
); );
t::lib::Mocks::mock_userenv( { patron => $patron1 } ); t::lib::Mocks::mock_userenv( { patron => $patron1 } );
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
my $recall1 = Koha::Recall->new( my $recall1 = Koha::Recall->new(
{ {
@ -3024,10 +3024,10 @@ subtest 'Recalls tests' => sub {
$recall2->set_cancelled; $recall2->set_cancelled;
t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'off' );
is( $item1->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall with UseRecalls disabled" ); is( $item1->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall with UseRecalls disabled" );
t::lib::Mocks::mock_preference( "UseRecalls", 1 ); t::lib::Mocks::mock_preference( "UseRecalls", 'opac' );
$item1->update( { notforloan => 1 } ); $item1->update( { notforloan => 1 } );
is( $item1->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall that is not for loan" ); is( $item1->can_be_recalled( { patron => $patron1 } ), 0, "Can't recall that is not for loan" );
@ -3247,7 +3247,7 @@ subtest 'has_pending_recall() tests' => sub {
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } );
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
C4::Circulation::AddIssue( $patron, $item->barcode ); C4::Circulation::AddIssue( $patron, $item->barcode );

View File

@ -1557,7 +1557,7 @@ subtest do_checkout_with_recalls => sub {
} }
); );
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
Koha::CirculationRules->set_rule( Koha::CirculationRules->set_rule(
{ {
branchcode => undef, branchcode => undef,

View File

@ -161,7 +161,7 @@ $contextmodule->mock(
} elsif ( $pref eq 'SearchLimitLibrary' ) { } elsif ( $pref eq 'SearchLimitLibrary' ) {
return 'both'; return 'both';
} elsif ( $pref eq 'UseRecalls' ) { } elsif ( $pref eq 'UseRecalls' ) {
return '0'; return 'off';
} elsif ( $pref eq 'ContentWarningField' ) { } elsif ( $pref eq 'ContentWarningField' ) {
return q{}; return q{};
} elsif ( $pref eq 'AuthorLinkSortBy' ) { } elsif ( $pref eq 'AuthorLinkSortBy' ) {

View File

@ -202,7 +202,7 @@ subtest 'buildKohaItemsNamespace status tests' => sub {
my $library_name = $holdinglibrary->branchname; my $library_name = $holdinglibrary->branchname;
like( $xml, qr{<resultbranch>${library_name}</resultbranch>}, "Found resultbranch / holding branch" ); like( $xml, qr{<resultbranch>${library_name}</resultbranch>}, "Found resultbranch / holding branch" );
t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'opac' );
my $recall = $builder->build_object( my $recall = $builder->build_object(
{ {
class => 'Koha::Recalls', class => 'Koha::Recalls',
@ -220,7 +220,7 @@ subtest 'buildKohaItemsNamespace status tests' => sub {
$xml, qr{<substatus>Recall waiting</substatus>}, $xml, qr{<substatus>Recall waiting</substatus>},
"Waiting status takes precedence over In transit (recalls)" "Waiting status takes precedence over In transit (recalls)"
); );
t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); t::lib::Mocks::mock_preference( 'UseRecalls', 'off' );
$schema->storage->txn_rollback; $schema->storage->txn_rollback;
}; };