Bug 13069 - (follow-up) Enable sort by title to ignore articles
[koha.git] / t / Creators.t
1 #!/usr/bin/perl
2 #
3 # This Koha test module is a stub!  
4 # Add more tests here!!!
5
6 use strict;
7 use warnings;
8
9 use Test::More tests => 16;
10
11 BEGIN {
12         use_ok('C4::Creators');
13         use_ok('C4::Creators::PDF');
14 }
15
16 my $pdf_creator = C4::Creators::PDF->new(InitVars => 0);
17 ok($pdf_creator, "testing new() works");
18 if (-e $pdf_creator->{filename}) {
19   pass('testing pdf file created');
20 }
21 else {
22   fail('testing pdf file created');
23 }
24
25 ok($pdf_creator->Add(""), "testing Add() works");
26 ok($pdf_creator->Bookmark({}), "testing Bookmark() works");
27 ok($pdf_creator->Compress(1), "testing Compress() works");
28
29 is($pdf_creator->Font("H"), "Ft1", "testing Font() works");
30 is($pdf_creator->FontSize(), '12', "testing FontSize() is set to 12 by default");
31 my @result = $pdf_creator->FontSize(14);
32 is($result[0], '14', "testing FontSize() can be set to a different value");
33 $pdf_creator->FontSize(); # Reset font size before testing text width etc below
34
35 ok($pdf_creator->Page(), "testing Page() works");
36
37 my $expected_width;
38 my $expected_offset;
39 if (C4::Context->config('ttf')) {
40     $expected_width  = '23.044921875';
41     $expected_offset = '33.044921875';
42 } else {
43     $expected_width  = '19.344';
44     $expected_offset = '29.344';
45 }
46
47 is($pdf_creator->StrWidth("test", "H", 12), $expected_width, "testing StrWidth() returns correct point width");
48
49 @result = $pdf_creator->Text(10, 10, "test");
50 is($result[0], '10', "testing Text() writes from a given x-value");
51 is($result[1], $expected_offset, "testing Text() writes to the correct x-value");
52
53 open(my $fh, '>', 'test.pdf');
54 select $fh;
55
56 ok($pdf_creator->End(), "testing End() works");
57
58 close($fh);
59 ok( -s 'test.pdf', 'test.pdf created' );
60
61 unlink 'test.pdf';