X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2FContext.t;h=e2c1825270e54219f7e804c2d1329258ee66cdf4;hb=a28334aeceba9ea8fcfcd301c4c01f473110bbe3;hp=6775b8e998abf720c63287f973dc373d9cbfefa6;hpb=850e7e58352fd1fcb2772308cbfc6375b6a45735;p=koha.git diff --git a/t/Context.t b/t/Context.t index 6775b8e998..e2c1825270 100755 --- a/t/Context.t +++ b/t/Context.t @@ -2,7 +2,7 @@ use Modern::Perl; use DBI; -use Test::More tests => 14; +use Test::More tests => 26; use Test::MockModule; BEGIN { @@ -45,3 +45,20 @@ 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','interface defaults to opac'); +is(C4::Context->interface('foobar'), 'opac', 'interface foobar'); +like($lastwarn, qr/invalid interface : 'foobar'/, 'interface warn on foobar'); +is(C4::Context->interface, 'opac', 'interface still opac'); +is(C4::Context->interface('intranet'), 'intranet', 'interface intranet'); +is(C4::Context->interface, 'intranet', 'interface still intranet'); +is(C4::Context->interface('foobar'), 'intranet', 'interface foobar again'); +is(C4::Context->interface, 'intranet', 'interface still intranet'); +is(C4::Context->interface('OPAC'), 'opac', 'interface OPAC uc'); +is(C4::Context->interface, 'opac', 'interface still opac'); +#Bug 14751 +is( C4::Context->interface( 'SiP' ), 'sip', 'interface SiP' ); +is( C4::Context->interface( 'COMMANDLINE' ), 'commandline', 'interface commandline uc' );