1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
use lib 't', 'lib';
use strict;
use warnings;
use Test::More;
eval "use Encode";
my $enc = ! $@;
use Spoon::ContentObject;
plan tests => 8;
my $database_directory;
{
no warnings;
package Spoon::ContentObject;
sub database_directory { $database_directory }
undef &Spoon::ContentObject::content;
field 'content';
}
{
$database_directory = 't/content';
my $object = Spoon::ContentObject->new(id => 'test1');
$object->load_content;
SKIP: {
skip "Encode not installed", 1 unless($enc);
ok( Encode::is_utf8( $object->content ), 'object content is utf8' );
}
is( $object->content, "This file has no utf8 in it.\n",
'test content was loaded' );
io->dir('t/tmp')->mkpath;
$database_directory = 't/tmp';
$object->force(1);
$object->store_content;
$object->load_content;
SKIP: {
skip "Encode not installed", 1 unless($enc);
ok( Encode::is_utf8( $object->content ), 'object content is utf8 after save/load' );
}
is( $object->content, "This file has no utf8 in it.\n",
'test content was loaded after save/load' );
}
{
$database_directory = 't/content';
my $object = Spoon::ContentObject->new(id => 'test2');
$object->load_content;
SKIP: {
skip "Encode not installed", 1 unless($enc);
ok( Encode::is_utf8( $object->content ), 'object content is utf8' );
}
is( $object->content, "This file has utf8 in it - \x{16A0}\x{16C7}\x{16BB}.\n",
'test content was loaded' );
io->dir('t/tmp')->mkpath;
$database_directory = 't/tmp';
$object->force(1);
$object->store_content;
$object->load_content;
SKIP: {
skip "Encode not installed", 1 unless($enc);
ok( Encode::is_utf8( $object->content ), 'object content is utf8 after save/load' );
}
is( $object->content, "This file has utf8 in it - \x{16A0}\x{16C7}\x{16BB}.\n",
'test content was loaded after save/load' );
}
|