Release a new CPAN version of Analysis
[scpubgit/stemmatology.git] / persistence / t / mysql_utf8.t
CommitLineData
6f9cd3b7 1#!/usr/bin/env perl
2
3use feature 'say';
4use strict;
5use warnings;
6use Test::More;
7use Test::More::UTF8;
8use Text::Tradition;
9use Text::Tradition::Directory;
10
11my $mysql_connect_info = $ENV{TT_MYSQL_TEST};
12plan skip_all => 'Please set TT_MYSQL_TEST to an appropriate db to run this test'
13 unless $mysql_connect_info;
14
15my @dbconnect = split( /;/, $mysql_connect_info );
16my $dsn = 'dbi:mysql:';
17my $user;
18my $pass;
19foreach my $item ( @dbconnect ) {
20 my( $k, $v ) = split( /=/, $item );
21 if( $k eq 'user' ) {
22 $user = $v;
23 } elsif( $k eq 'password' ) {
24 $pass = $v;
25 } else {
26 $dsn .= "$item;";
27 }
28}
29
30my $dir = Text::Tradition::Directory->new( 'dsn' => $dsn,
3051d8a9 31 'extra_args' => { 'user' => $user, 'password' => $pass, 'create' => 1,
6f9cd3b7 32 dbi_attrs => { 'mysql_enable_utf8' => 1 } },
33 );
34
35my $scope = $dir->new_scope();
36
37my $utf8_t = Text::Tradition->new(
38 'input' => 'Self',
39 'file' => 't/data/florilegium_graphml.xml' );
40my $uuid = $dir->save( $utf8_t );
41foreach my $tinfo( $dir->traditionlist ) {
42 next unless $tinfo->{id} eq $uuid;
43 like( $tinfo->{name}, qr/\x{3b2}/, "Tradition name encoded correctly" );
44}
45
46done_testing();