utf8columns fix
[dbsrgits/DBIx-Class.git] / t / 85utf8.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 eval 'use Encode ; 1'
11     or plan skip_all => 'Install Encode run this test';
12
13 plan tests => 3;
14
15 DBICTest::Schema::CD->load_components('UTF8Columns');
16 DBICTest::Schema::CD->utf8_columns('title');
17 Class::C3->reinitialize();
18
19 my $cd = $schema->resultset('CD')->create( { artist => 1, title => 'uni', year => 'foo' } );
20 ok( Encode::is_utf8( $cd->title ), 'got title with utf8 flag' );
21 ok( !Encode::is_utf8( $cd->year ), 'got year without utf8 flag' );
22
23 my $utf8_char = 'uniuni';
24 Encode::_utf8_on($utf8_char);
25 $cd->title($utf8_char);
26 ok( !Encode::is_utf8( $cd->{_column_data}{title} ),
27     'store utf8-less chars' );
28