5.8.1 is minimum required perl
[dbsrgits/DBIx-Class.git] / t / 85utf8.t
CommitLineData
70350518 1use strict;
55087b99 2use warnings;
e59c17fe 3
70350518 4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
55087b99 7use utf8;
e59c17fe 8
a47e1233 9my $schema = DBICTest->init_schema();
e59c17fe 10
404939a4 11DBICTest::Schema::CD->load_components('UTF8Columns');
12DBICTest::Schema::CD->utf8_columns('title');
70350518 13Class::C3->reinitialize();
14
db087eb1 15my $cd = $schema->resultset('CD')->create( { artist => 1, title => 'øni', year => '2048' } );
70350518 16my $utf8_char = 'uniuni';
e59c17fe 17
337c98ef 18
55087b99 19ok( utf8::is_utf8( $cd->title ), 'got title with utf8 flag' );
20ok(! utf8::is_utf8( $cd->year ), 'got year without utf8 flag' );
337c98ef 21
55087b99 22utf8::decode($utf8_char);
db087eb1 23$cd->title($utf8_char);
55087b99 24ok(! utf8::is_utf8( $cd->{_column_data}{title} ), 'store utf8-less chars' );
337c98ef 25
1d0057bd 26
27my $v_utf8 = "\x{219}";
28
29$cd->update ({ title => $v_utf8 });
30$cd->title($v_utf8);
31ok( !$cd->is_column_changed('title'), 'column is not dirty after setting the same unicode value' );
32
33$cd->update ({ title => $v_utf8 });
34$cd->title('something_else');
35ok( $cd->is_column_changed('title'), 'column is dirty after setting to something completely different');
db087eb1 36
37TODO: {
38 local $TODO = 'There is currently no way to propagate aliases to inflate_result()';
39 $cd = $schema->resultset('CD')->find ({ title => $v_utf8 }, { select => 'title', as => 'name' });
55087b99 40 ok (utf8::is_utf8( $cd->get_column ('name') ), 'utf8 flag propagates via as');
db087eb1 41}
42
55087b99 43done_testing;