Bug 34094: (follow-up) Fix failing unit test

The unit tests were written to assume we always do a 'contains' search,
but the new system preference allows for 'starts_with' or 'contains'.

As such, for the tests to pass, we need to explicitly mock the
preference to 'contains'

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2023-07-11 14:26:46 +01:00 committed by Tomas Cohen Arazi
parent 28d7108624
commit b787e66fef
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -74,6 +74,7 @@ subtest 'Search patrons' => sub {
{ class => 'Koha::Libraries', value => { branchname => $branchname } }
);
my $default_patron_search_fields = C4::Context->preference('DefaultPatronSearchFields');
my $default_patron_search_method = C4::Context->preference('DefaultPatronSearchMethod');
my $default_patron_per_page = C4::Context->preference('PatronsPerPage');
for my $i ( 1 .. 25 ) {
push @patrons,
@ -155,6 +156,7 @@ subtest 'Search patrons' => sub {
$s->auth;
C4::Context->set_preference('DefaultPatronSearchFields',"");
C4::Context->set_preference('DefaultPatronSearchMethod',"contains");
my $PatronsPerPage = 15;
my $nb_standard_fields = 13;
C4::Context->set_preference('PatronsPerPage', $PatronsPerPage);
@ -335,6 +337,7 @@ subtest 'Search patrons' => sub {
push @cleanup, $patron_category;
push @cleanup, $attribute_type, $attribute_type_searchable;
C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields);
C4::Context->set_preference('DefaultPatronSearchMethod',$default_patron_search_method);
C4::Context->set_preference('PatronsPerPage',$default_patron_per_page);
$driver->quit();