Bug 11587 - IsSuperLibrarian generates warnings (UT)
authorMark Tompsett <mtompset@hotmail.com>
Tue, 21 Jan 2014 05:34:43 +0000 (00:34 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 10 Mar 2014 15:55:12 +0000 (15:55 +0000)
Simply viewing OPAC detail triggers a modulus warning entry.
This first patch adds two test cases to t/Context.t to test for
this situation.

TEST PLAN
---------
1) Apply this patch (to upgrade t/Context.t)
2) prove -v t/Context.t
-- Tests 7 and 8 will fail
3) Apply main patch (to amend C4/Context.pm)
4) prove -v t/Context.t
-- All tests will succeed

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/Context.t

index 446e254..46e353e 100755 (executable)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 use DBI;
-use Test::More tests => 10;
+use Test::More tests => 12;
 use Test::MockModule;
 
 BEGIN {
@@ -31,6 +31,11 @@ $is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
 is ( $@, q||, "IsSuperLibrarian does not log an error if userenv is defined" );
 is ( $is_super_librarian, 1, "With flag=1, it is a super librarian" );
 
+$userenv->{flags} = undef;
+$is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
+is ( $@, q||, "IsSuperLibrarian does not log an error if \$userenv->{flags} is undefined" );
+is ( $is_super_librarian, 0, "With flag=0, it is not a super librarian" );
+
 is(C4::Context::db_scheme2dbi('mysql'), 'mysql', 'ask for mysql, get mysql');
 is(C4::Context::db_scheme2dbi('Pg'),    'Pg',    'ask for Pg, get Pg');
 is(C4::Context::db_scheme2dbi('xxx'),   'mysql', 'ask for unsupported DBMS, get mysql');