Commit | Line | Data |
6f9cd3b7 |
1 | #!/usr/bin/env perl |
2 | |
3 | use feature 'say'; |
4 | use strict; |
5 | use warnings; |
6 | use Test::More; |
7 | use Test::More::UTF8; |
8 | use Text::Tradition; |
9 | use Text::Tradition::Directory; |
10 | |
11 | my $mysql_connect_info = $ENV{TT_MYSQL_TEST}; |
12 | plan skip_all => 'Please set TT_MYSQL_TEST to an appropriate db to run this test' |
13 | unless $mysql_connect_info; |
14 | |
15 | my @dbconnect = split( /;/, $mysql_connect_info ); |
16 | my $dsn = 'dbi:mysql:'; |
17 | my $user; |
18 | my $pass; |
19 | foreach 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 | |
30 | my $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 | |
35 | my $scope = $dir->new_scope(); |
36 | |
37 | my $utf8_t = Text::Tradition->new( |
38 | 'input' => 'Self', |
39 | 'file' => 't/data/florilegium_graphml.xml' ); |
40 | my $uuid = $dir->save( $utf8_t ); |
41 | foreach my $tinfo( $dir->traditionlist ) { |
42 | next unless $tinfo->{id} eq $uuid; |
43 | like( $tinfo->{name}, qr/\x{3b2}/, "Tradition name encoded correctly" ); |
44 | } |
45 | |
46 | done_testing(); |