skip tests unless DBD::SQLite installed
[blog.pm-common-perl-mods.git] / Rose-DBx-Object-I18N / t / available-translations.t
blob42066816cdc5a606d8f0ab220feb3c1772c66061
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More;
8 eval "use DBD::SQLite";
9 plan skip_all => "DBD::SQLite is required to run this test" if $@;
11 plan 'tests' => 5;
13 use lib 't/lib';
15 use NewDB;
16 use User;
18 my $db = NewDB->new();
20 $db->init();
22 my $u = User->new(
23 name => 'oooo',
24 orig_lang => 'ru',
25 signature => 'hello'
27 $u->save();
29 $ENV{ RDBO_I18N_LANG } = 'ru';
30 $u = User->new( id => $u->id );
31 $u->load();
33 $u->i18n();
34 is_deeply( $u->i18n_available_translations, [] );
36 $u->i18n( 'en' )->signature( 'hello2' );
37 $u->save();
39 is( $u->i18n_is_original_loaded(), 0 );
40 is_deeply( $u->i18n_available_translations, [ 'ru' ] );
42 $u->i18n( 'ru' );
43 is_deeply( $u->i18n_available_translations, [ 'en' ] );
45 $u->i18n( 'ua' );
46 is_deeply( $u->i18n_available_translations, [ 'en' ] );
48 $u->delete( cascade => 1 );