Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 4 | use Test::XML::Loy; |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 5 | |
| 6 | use FindBin; |
| 7 | BEGIN { |
| 8 | unshift @INC, "$FindBin::Bin/../lib"; |
| 9 | }; |
| 10 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 11 | use_ok('Test::KorAP::XML::TEI','korap_tempfile', 'i5_template'); |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 12 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 13 | subtest 'korap_tempfile' => sub { |
| 14 | my ($fh, $filename) = korap_tempfile('test'); |
| 15 | ok($fh, 'Filehandle created'); |
| 16 | ok($filename, 'Filename returned'); |
| 17 | close($fh); |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 18 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 19 | like($filename, qr!KorAP-XML-TEI_test_.+?\.tmp$!, 'Filename pattern'); |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 20 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 21 | ($fh, $filename) = korap_tempfile(); |
| 22 | ok($fh, 'Filehandle created'); |
| 23 | ok($filename, 'Filename returned'); |
| 24 | close($fh); |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 25 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 26 | like($filename, qr!KorAP-XML-TEI_.+?\.tmp$!, 'Filename pattern'); |
| 27 | }; |
| 28 | |
| 29 | subtest '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 | }; |
Akron | 5fb5e8d | 2020-07-23 17:45:13 +0200 | [diff] [blame] | 52 | |
| 53 | done_testing; |