Bug 8435: (follow-up) handle lack of userenv gracefully
[koha.git] / t / db_dependent / Koha_Database.t
1 #!/usr/bin/perl
2 #
3
4 use strict;
5 use warnings;
6
7 use Test::More tests => 9;
8
9 BEGIN {
10     use_ok('Koha::Database');
11 }
12
13 my $database;
14 ok( $database = Koha::Database->new(), 'Created Koha::Database Object' );
15
16 my $schema;
17 ok( $schema = $database->schema(), 'Get a schema' );
18 my $dbh;
19 ok( $dbh = $schema->storage->dbh(), 'Get an old fashioned DBI dbh handle' );
20 ok( $schema->storage->connected(), 'Check our db connection is active' );
21 ok( $schema = $database->schema(), 'Try and get the same schema' );
22
23 my $new_schema;
24 ok( $new_schema = $database->new_schema(), 'Try to get a new schema' );
25 ok( $database->set_schema($new_schema), 'Switch to new schema' );
26 ok( $database->restore_schema(),        'Switch back' );
27