| File: | t/Creators.t |
| Coverage: | 94.6% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | #!/usr/bin/perl | |||||
| 2 | # | |||||
| 3 | # This Koha test module is a stub! | |||||
| 4 | # Add more tests here!!! | |||||
| 5 | ||||||
| 6 | 1 1 1 | 1.33283522902483e+15 19 42 | use strict; | |||
| 7 | 1 1 1 | 19 14 50 | use warnings; | |||
| 8 | ||||||
| 9 | 1 1 1 | 264 19062 67 | use Test::More tests => 15; | |||
| 10 | ||||||
| 11 | BEGIN { | |||||
| 12 | 1 | 1523 | use_ok('C4::Creators'); | |||
| 13 | 1 | 633 | use_ok('C4::Creators::PDF'); | |||
| 14 | } | |||||
| 15 | ||||||
| 16 | 1 | 477317 | my $pdf_creator = C4::Creators::PDF->new('test.pdf' => '', InitVars => 0); | |||
| 17 | 1 | 27 | ok($pdf_creator, "testing new() works"); | |||
| 18 | 1 | 710 | if (-e 'test.pdf') { | |||
| 19 | 1 | 9 | pass('testing pdf file created'); | |||
| 20 | } | |||||
| 21 | else { | |||||
| 22 | 0 | 0 | fail('testing pdf file created'); | |||
| 23 | } | |||||
| 24 | ||||||
| 25 | 1 | 432 | ok($pdf_creator->Add(""), "testing Add() works"); | |||
| 26 | 1 | 416 | ok($pdf_creator->Bookmark({}), "testing Bookmark() works"); | |||
| 27 | 1 | 484 | ok($pdf_creator->Compress(1), "testing Compress() works"); | |||
| 28 | ||||||
| 29 | 1 | 383 | is($pdf_creator->Font("H"), "Ft1", "testing Font() works"); | |||
| 30 | 1 | 665 | is($pdf_creator->FontSize(), '12', "testing FontSize() is set to 12 by default"); | |||
| 31 | 1 | 534 | my @result = $pdf_creator->FontSize(14); | |||
| 32 | 1 | 20 | is($result[0], '14', "testing FontSize() can be set to a different value"); | |||
| 33 | 1 | 609 | $pdf_creator->FontSize(); # Reset font size before testing text width etc below | |||
| 34 | ||||||
| 35 | 1 | 17 | ok($pdf_creator->Page(), "testing Page() works"); | |||
| 36 | ||||||
| 37 | 1 | 1397 | is($pdf_creator->StrWidth("test", "H", 12), '19.344', "testing StrWidth() returns correct point width"); | |||
| 38 | ||||||
| 39 | 1 | 4655 | @result = $pdf_creator->Text(10, 10, "test"); | |||
| 40 | 1 | 125 | is($result[0], '10', "testing Text() writes from a given x-value"); | |||
| 41 | 1 | 509 | is($result[1], '29.344', "testing Text() writes to the correct x-value"); | |||
| 42 | ||||||
| 43 | 1 | 513 | ok($pdf_creator->End(), "testing End() works"); | |||
| 44 | ||||||
| 45 | 1 | 191114 | unlink 'test.pdf'; | |||