Bug 11650: multiplicated authorities after link_bibs_to_authorities.pl
[koha_fer] / t / Creators.t
index 720aa2c..646aef5 100755 (executable)
@@ -6,16 +6,16 @@
 use strict;
 use warnings;
 
-use Test::More tests => 15;
+use Test::More tests => 16;
 
 BEGIN {
         use_ok('C4::Creators');
         use_ok('C4::Creators::PDF');
 }
 
-my $pdf_creator = C4::Creators::PDF->new('test.pdf' => '', InitVars => 0);
+my $pdf_creator = C4::Creators::PDF->new(InitVars => 0);
 ok($pdf_creator, "testing new() works");
-if (-e 'test.pdf') {
+if (-e $pdf_creator->{filename}) {
   pass('testing pdf file created');
 }
 else {
@@ -34,12 +34,28 @@ $pdf_creator->FontSize(); # Reset font size before testing text width etc below
 
 ok($pdf_creator->Page(), "testing Page() works");
 
-is($pdf_creator->StrWidth("test", "H", 12), '19.344', "testing StrWidth() returns correct point width");
+my $expected_width;
+my $expected_offset;
+if (C4::Context->config('ttf')) {
+    $expected_width  = '23.044921875';
+    $expected_offset = '33.044921875';
+} else {
+    $expected_width  = '19.344';
+    $expected_offset = '29.344';
+}
+
+is($pdf_creator->StrWidth("test", "H", 12), $expected_width, "testing StrWidth() returns correct point width");
 
 @result = $pdf_creator->Text(10, 10, "test");
 is($result[0], '10', "testing Text() writes from a given x-value");
-is($result[1], '29.344', "testing Text() writes to the correct x-value");
+is($result[1], $expected_offset, "testing Text() writes to the correct x-value");
+
+open(my $fh, '>', 'test.pdf');
+select $fh;
 
 ok($pdf_creator->End(), "testing End() works");
 
+close($fh);
+ok( -s 'test.pdf', 'test.pdf created' );
+
 unlink 'test.pdf';