From: Jens Gassmann Date: Sat, 11 Apr 2015 09:52:54 +0000 (+0200) Subject: Adding a test for unicode X-Git-Tag: v1.001_030~5^2^2~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=593b3c236f6c977bd42827c3b18874bb86b1c645;p=dbsrgits%2FDBIx-Class-Fixtures.git Adding a test for unicode --- diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 81b2569..36f8d0e 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -898,6 +898,7 @@ sub dump_object { # do the actual dumping my $serialized = Dump(\%ds)->Out(); + $file->print($serialized); } diff --git a/t/19-populate-unicode.t b/t/19-populate-unicode.t new file mode 100644 index 0000000..ab5fce1 --- /dev/null +++ b/t/19-populate-unicode.t @@ -0,0 +1,53 @@ +#!perl + +use DBIx::Class::Fixtures; +use Test::More no_plan; +use lib qw(t/lib); +use DBICTest; +use Path::Class; +use Data::Dumper; +use IO::All; +use utf8; + +# set up and populate schema +ok( my $schema = DBICTest->init_schema(), 'got schema' ); +my $config_dir = io->catfile(qw't var configs')->name; + +# do dump +ok( + my $fixtures = DBIx::Class::Fixtures->new( + { + config_dir => $config_dir, + debug => 0 + } + ), + 'object created with correct config dir' +); + +DBICTest->clear_schema($schema); +DBICTest->populate_schema($schema); + +ok( + $fixtures->dump( + { + schema => $schema, + directory => io->catfile(qw't var fixtures')->name, + config => "unicode.json", + } + ), + "unicode dump executed okay" +); + +$fixtures->populate( + { + connection_details => [ 'dbi:SQLite:' . io->catfile(qw[ t var DBIxClass.db ])->name, '', '' ], + directory => io->catfile(qw't var fixtures')->name, + schema => $schema, + no_deploy => 1, + use_find_or_create => 1, + } +); + +my $cd = $schema->resultset('CD')->find( { cdid => 5 }); + +is($cd->title, "Unicode Chars ™ © • † ∑ α β « » → …", "Unicode chars found"); diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 8e4c560..69d0c74 100755 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -160,7 +160,7 @@ sub populate_schema { [ 2, 1, "Forkful of bees", 2001 ], [ 3, 1, "Caterwaulin' Blues", 1997 ], [ 4, 2, "Generic Manufactured Singles", 2001 ], - [ 5, 2, "Wir übertreiben überhaupt nicht", 2003 ], + [ 5, 2, "Unicode Chars ™ © • † ∑ α β « » → …", 2015 ], [ 6, 3, "Come Be Depressed With Us", 1998 ], ]); diff --git a/t/var/configs/unicode.json b/t/var/configs/unicode.json new file mode 100644 index 0000000..adc21a6 --- /dev/null +++ b/t/var/configs/unicode.json @@ -0,0 +1,12 @@ +{ + "might_have": { + "fetch": 0 + }, + "has_many": { + "fetch": 0 + }, + "sets": [{ + "class": "CD", + "quantity": "all" + }] +} diff --git a/t/var/fixtures/CD/5.fix b/t/var/fixtures/CD/5.fix index 7fb848f..0912382 100644 --- a/t/var/fixtures/CD/5.fix +++ b/t/var/fixtures/CD/5.fix @@ -1,6 +1,6 @@ $HASH1 = { artist => 2, cdid => 5, - title => "Wir \374bertreiben \374berhaupt nicht", - year => 2003 + title => "Unicode Chars \x{2122} \251 \x{2022} \x{2020} \x{2211} \x{3b1} \x{3b2} \253 \273 \x{2192} \x{2026}", + year => 2015 };