Bug 9811: Remove useless orderby management
[koha_fer] / t / Context.t
index 446e254..8febdb4 100755 (executable)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 use DBI;
-use Test::More tests => 10;
+use Test::More tests => 24;
 use Test::MockModule;
 
 BEGIN {
@@ -31,7 +31,31 @@ $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=undef, it is not a super librarian" );
+
+$userenv->{flags} = 0;
+$is_super_librarian = eval{ C4::Context::IsSuperLibrarian() };
+is ( $@, q||, "IsSuperLibrarian does not log an error if \$userenv->{flags} is equal to 0" );
+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');
 is(C4::Context::db_scheme2dbi(),        'mysql', 'ask for nothing, get mysql');
+
+# C4::Context::interface
+my $lastwarn;
+local $SIG{__WARN__} = sub { $lastwarn = $_[0] };
+is(C4::Context->interface, 'opac');
+is(C4::Context->interface('foobar'), 'opac');
+like($lastwarn, qr/invalid interface : 'foobar'/);
+is(C4::Context->interface, 'opac');
+is(C4::Context->interface('intranet'), 'intranet');
+is(C4::Context->interface, 'intranet');
+is(C4::Context->interface('foobar'), 'intranet');
+is(C4::Context->interface, 'intranet');
+is(C4::Context->interface('OPAC'), 'opac');
+is(C4::Context->interface, 'opac');