Bug 21911: Regression test
authorJosef Moravec <josef.moravec@gmail.com>
Fri, 30 Nov 2018 07:09:23 +0000 (07:09 +0000)
committerJesse Maseto <jesse@bywatersolution.com>
Tue, 18 Dec 2018 19:08:46 +0000 (19:08 +0000)
This tests usuall cases, but note, that administrator could make a
branch with code "%%%" or so, which this test does not cover, and some
functionalities will not work in that case: opac limit override,
                holdinbranch facet

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit e5585a10d5f2ee24cad94b2cf17df1ce13e8a01a)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 2e6c3b19899c51b801cc5647259793206e2de622)

t/db_dependent/Auth.t

index c8fb1f1..ecad00c 100644 (file)
@@ -10,7 +10,7 @@ use CGI qw ( -utf8 );
 use Test::MockObject;
 use Test::MockModule;
 use List::MoreUtils qw/all any none/;
-use Test::More tests => 22;
+use Test::More tests => 26;
 use Test::Warn;
 use t::lib::Mocks;
 use t::lib::TestBuilder;
@@ -253,6 +253,34 @@ my $hash2 = hash_password('password');
     );
     my $file_exists = ( -f $template->{filename} ) ? 1 : 0;
     is ( $file_exists, 1, 'The file errors/errorpage.tt should be accessible (contains integers)' );
+
+    # Regression test for env opac search limit override
+    $ENV{"OPAC_SEARCH_LIMIT"} = "branch:CPL";
+    $ENV{"OPAC_LIMIT_OVERRIDE"} = 1;
+
+    ( $template, $loggedinuser, $cookies) = get_template_and_user(
+        {
+            template_name => 'opac-main.tt',
+            query => $query,
+            type => 'opac',
+            authnotrequired => 1,
+        }
+    );
+    is($template->{VARS}->{'opac_name'}, "CPL", "Opac name was set correctly");
+    is($template->{VARS}->{'opac_search_limit'}, "branch:CPL", "Search limit was set correctly");
+
+    $ENV{"OPAC_SEARCH_LIMIT"} = "branch:multibranch-19";
+
+    ( $template, $loggedinuser, $cookies) = get_template_and_user(
+        {
+            template_name => 'opac-main.tt',
+            query => $query,
+            type => 'opac',
+            authnotrequired => 1,
+        }
+    );
+    is($template->{VARS}->{'opac_name'}, "multibranch-19", "Opac name was set correctly");
+    is($template->{VARS}->{'opac_search_limit'}, "branch:multibranch-19", "Search limit was set correctly");
 }
 
 # Check that there is always an OPACBaseURL set.