Improve i5 template testing
Change-Id: I1bfa22acf3ff9173d26edd9c0edaefe4c7fe3208
diff --git a/t/test.t b/t/test.t
index 5b6fbe1..de0c65e 100644
--- a/t/test.t
+++ b/t/test.t
@@ -1,26 +1,53 @@
use strict;
use warnings;
use Test::More;
+use Test::XML::Loy;
use FindBin;
BEGIN {
unshift @INC, "$FindBin::Bin/../lib";
};
-use_ok('Test::KorAP::XML::TEI','korap_tempfile');
+use_ok('Test::KorAP::XML::TEI','korap_tempfile', 'i5_template');
-my ($fh, $filename) = korap_tempfile('test');
-ok($fh, 'Filehandle created');
-ok($filename, 'Filename returned');
-close($fh);
+subtest 'korap_tempfile' => sub {
+ my ($fh, $filename) = korap_tempfile('test');
+ ok($fh, 'Filehandle created');
+ ok($filename, 'Filename returned');
+ close($fh);
-like($filename, qr!KorAP-XML-TEI_test_.+?\.tmp$!, 'Filename pattern');
+ like($filename, qr!KorAP-XML-TEI_test_.+?\.tmp$!, 'Filename pattern');
-($fh, $filename) = korap_tempfile();
-ok($fh, 'Filehandle created');
-ok($filename, 'Filename returned');
-close($fh);
+ ($fh, $filename) = korap_tempfile();
+ ok($fh, 'Filehandle created');
+ ok($filename, 'Filename returned');
+ close($fh);
-like($filename, qr!KorAP-XML-TEI_.+?\.tmp$!, 'Filename pattern');
+ like($filename, qr!KorAP-XML-TEI_.+?\.tmp$!, 'Filename pattern');
+};
+
+subtest 'i5_template' => sub {
+ my $tpl = i5_template();
+ my $t = Test::XML::Loy->new($tpl);
+ $t->text_is('korpusSigle', 'AAA')
+ ->text_is('dokumentSigle', 'AAA/BBB')
+ ->text_is('textSigle', 'AAA/BBB.00000')
+ ->text_like('text', qr!Lorem ipsum!)
+ ;
+
+ $tpl = i5_template(
+ korpusSigle => 'BBB',
+ dokumentSigle => 'BBB/CCC',
+ textSigle => 'BBB/CCC.11111',
+ text => 'Ein Versuch'
+ );
+ $t = Test::XML::Loy->new($tpl);
+ $t->text_is('korpusSigle', 'BBB')
+ ->text_is('dokumentSigle', 'BBB/CCC')
+ ->text_is('textSigle', 'BBB/CCC.11111')
+ ->text_unlike('text', qr!Lorem ipsum!)
+ ->text_like('text', qr!Ein Versuch!)
+ ;
+};
done_testing;