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