Big LDAP changes, module test for Context.pm, still more yet to come.
[koha.git] / t / Context.t
1 #!/usr/bin/perl
2 #
3
4 use strict;
5 use warnings;
6
7 use Test::More tests => 91;
8 use vars qw($debug $koha $dbh $config $ret);
9
10 BEGIN {
11                 $debug = $ENV{DEBUG} || 0;
12                 diag("Note: The overall number of tests may vary by configuration.");
13                 diag("First we need to check your environmental variables");
14                 for (qw(KOHA_CONF PERL5LIB)) {
15                         ok($ret = $ENV{$_}, "ENV{$_} = $ret");
16                 }
17                 use_ok('C4::Context');
18                 use_ok('C4::Utils', qw/ :all /);
19 }
20
21 ok($koha = C4::Context->new,  'C4::Context->new');
22 ok($dbh = C4::Context->dbh(), 'Getting dbh from C4::Context');
23 ok($ret = C4::Context->KOHAVERSION, '  (function)  KOHAVERSION = ' . ($ret||''));
24 ok($ret =       $koha->KOHAVERSION, '       $koha->KOHAVERSION = ' . ($ret||''));
25 my @keys = keys %$koha;
26 diag("Number of keys in \%\$koha: " . scalar @keys); 
27 our $width = 0;
28 if (ok(@keys)) { 
29         $width = maxwidth(@keys);
30         $debug and diag "widest key is $width";
31 }
32 foreach (sort @keys) {
33         ok(exists $koha->{$_}, 
34                 '$koha->{' . sprintf('%' . $width . 's', $_)  . '} exists '
35                 . ((defined $koha->{$_}) ? "and is defined." : "but is not defined.")
36         );
37 }
38 diag "Examining defined key values.";
39 foreach (grep {defined $koha->{$_}} sort @keys) {
40         print "\n";
41         hashdump('$koha->{' . sprintf('%' . $width . 's', $_)  . '}', $koha->{$_});
42 }
43 ok($config = $koha->{config}, 'Getting $koha->{config} ');
44
45 # diag("Examining configuration.");
46 diag("Note: The overall number of tests may vary by configuration.  Disregard the projected number.");
47 1;
48 __END__
49