Bug 13940 : (QA followup) Add test for ModOAISet
[koha.git] / t / db_dependent / Context.t
index 32ea441..feb2a43 100755 (executable)
@@ -10,13 +10,12 @@ use vars qw($debug $koha $dbh $config $ret);
 
 BEGIN {
                $debug = $ENV{DEBUG} || 0;
-               diag("Note: The overall number of tests may vary by configuration.");
-               diag("First we need to check your environmental variables");
+        # Note: The overall number of tests may vary by configuration.
+        # First we need to check your environmental variables
                for (qw(KOHA_CONF PERL5LIB)) {
                        ok($ret = $ENV{$_}, "ENV{$_} = $ret");
                }
                use_ok('C4::Context');
-               use_ok('C4::Utils', qw/ :all /);
 }
 
 ok($koha = C4::Context->new,  'C4::Context->new');
@@ -29,11 +28,10 @@ ok(
     'Final linear version is less than or equal to kohaversion.pl'
 );
 my @keys = keys %$koha;
-diag("Number of keys in \%\$koha: " . scalar @keys); 
-our $width = 0;
+my $width = 0;
 if (ok(@keys)) { 
-       $width = maxwidth(@keys);
-       $debug and diag "widest key is $width";
+    $width = (sort {$a <=> $b} map {length} @keys)[-1];
+    $debug and diag "widest key is $width";
 }
 foreach (sort @keys) {
        ok(exists $koha->{$_}, 
@@ -41,18 +39,9 @@ foreach (sort @keys) {
                . ((defined $koha->{$_}) ? "and is defined." : "but is not defined.")
        );
 }
-diag "Examining defined key values.";
-foreach (grep {defined $koha->{$_}} sort @keys) {
-       print "\n";
-       hashdump('$koha->{' . sprintf('%' . $width . 's', $_)  . '}', $koha->{$_});
-}
 ok($config = $koha->{config}, 'Getting $koha->{config} ');
 
-diag "Testing syspref caching.";
-
-my $dbh = C4::Context->dbh;
-$dbh->disconnect;
-
+# Testing syspref caching
 my $module = new Test::MockModule('C4::Context');
 $module->mock(
     '_new_dbh',
@@ -64,7 +53,7 @@ $module->mock(
 );
 
 my $history;
-$dbh = C4::Context->dbh;
+$dbh = C4::Context->dbh({ new => 1 });
 
 $dbh->{mock_add_resultset} = [ ['value'], ['thing1'] ];
 $dbh->{mock_add_resultset} = [ ['value'], ['thing2'] ];
@@ -107,6 +96,11 @@ is(C4::Context->preference("SillyPreference"), 'thing4', "Retrieved syspref (val
 $history = $dbh->{mock_all_history};
 is(scalar(@{$history}), 0, 'Did not retrieve syspref from database');
 
+my $oConnection = C4::Context->Zconn('biblioserver', 0);
+isnt($oConnection->option('async'), 1, "ZOOM connection is synchronous");
+$oConnection = C4::Context->Zconn('biblioserver', 1);
+is($oConnection->option('async'), 1, "ZOOM connection is asynchronous");
+
 done_testing();
 
 sub TransformVersionToNum {