blob: de0c65e70c41acc55e02d811d25243ddf633160b [file] [log] [blame]
Akron5fb5e8d2020-07-23 17:45:13 +02001use strict;
2use warnings;
3use Test::More;
Akron54e363c2020-07-29 11:01:03 +02004use Test::XML::Loy;
Akron5fb5e8d2020-07-23 17:45:13 +02005
6use FindBin;
7BEGIN {
8 unshift @INC, "$FindBin::Bin/../lib";
9};
10
Akron54e363c2020-07-29 11:01:03 +020011use_ok('Test::KorAP::XML::TEI','korap_tempfile', 'i5_template');
Akron5fb5e8d2020-07-23 17:45:13 +020012
Akron54e363c2020-07-29 11:01:03 +020013subtest 'korap_tempfile' => sub {
14 my ($fh, $filename) = korap_tempfile('test');
15 ok($fh, 'Filehandle created');
16 ok($filename, 'Filename returned');
17 close($fh);
Akron5fb5e8d2020-07-23 17:45:13 +020018
Akron54e363c2020-07-29 11:01:03 +020019 like($filename, qr!KorAP-XML-TEI_test_.+?\.tmp$!, 'Filename pattern');
Akron5fb5e8d2020-07-23 17:45:13 +020020
Akron54e363c2020-07-29 11:01:03 +020021 ($fh, $filename) = korap_tempfile();
22 ok($fh, 'Filehandle created');
23 ok($filename, 'Filename returned');
24 close($fh);
Akron5fb5e8d2020-07-23 17:45:13 +020025
Akron54e363c2020-07-29 11:01:03 +020026 like($filename, qr!KorAP-XML-TEI_.+?\.tmp$!, 'Filename pattern');
27};
28
29subtest 'i5_template' => sub {
30 my $tpl = i5_template();
31 my $t = Test::XML::Loy->new($tpl);
32 $t->text_is('korpusSigle', 'AAA')
33 ->text_is('dokumentSigle', 'AAA/BBB')
34 ->text_is('textSigle', 'AAA/BBB.00000')
35 ->text_like('text', qr!Lorem ipsum!)
36 ;
37
38 $tpl = i5_template(
39 korpusSigle => 'BBB',
40 dokumentSigle => 'BBB/CCC',
41 textSigle => 'BBB/CCC.11111',
42 text => 'Ein Versuch'
43 );
44 $t = Test::XML::Loy->new($tpl);
45 $t->text_is('korpusSigle', 'BBB')
46 ->text_is('dokumentSigle', 'BBB/CCC')
47 ->text_is('textSigle', 'BBB/CCC.11111')
48 ->text_unlike('text', qr!Lorem ipsum!)
49 ->text_like('text', qr!Ein Versuch!)
50 ;
51};
Akron5fb5e8d2020-07-23 17:45:13 +020052
53done_testing;