Bug 26214: Remove the use of jquery.checkboxes plugin on late orders page
[koha.git] / t / db_dependent / Koha_Database.t
blobd950cb9ad7e0baa43b33e440ee2ba06a8d4763a6
1 #!/usr/bin/perl
4 use Modern::Perl;
5 use utf8;
7 use Test::More tests => 12;
9 BEGIN {
10 use_ok('Koha::Database');
13 my $database;
14 ok( $database = Koha::Database->new(), 'Created Koha::Database Object' );
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 is( ref($schema), 'Koha::Schema', 'Koha::Database->new->schema should return a Koha::Schema' );
22 my $another_schema = $database->schema();
23 is( $another_schema->storage->_conn_pid, $schema->storage->_conn_pid, 'Getting another schema should return the same one, it has correctly been cached' );
24 $another_schema = Koha::Database->new->schema();
25 is( $another_schema->storage->_conn_pid, $schema->storage->_conn_pid, 'Getting another schema should return the same one, it has correctly been cached' );
27 my $new_schema;
28 ok( $new_schema = $database->new_schema(), 'Try to get a new schema' );
29 ok( $database->set_schema($new_schema), 'Switch to new schema' );
30 ok( $database->restore_schema(), 'Switch back' );
32 # run in a transaction
33 $schema->storage->txn_begin();
35 # clear the way
36 $schema->resultset('Category')->search({ categorycode => 'GIFT-RUS' })->delete;
37 my $gift = 'подарок';
38 $schema->resultset('Category')->create({
39 categorycode => 'GIFT-RUS',
40 description => $gift,
41 });
42 my $desc = $schema->resultset('Category')->search({
43 categorycode => 'GIFT-RUS',
44 })->single->get_column('description');
45 is($desc, $gift, 'stored and retrieved UTF8 string');
46 $schema->storage->txn_rollback();