Mason James
80abbe1fa3
to test.. 1/ run t/Creators.t test from git repo, get a FAIL 2/ apply patch 3/ repeat step 1, get a PASS mason@xen1:~/g/k/3.16.x$ sudo koha-shell -c 'export PERL5LIB=/home/mason/g/k/3.16.x ; cd /home/mason/g/k/3.16.x ; prove -v t/Creators.t' k316x1 t/Creators.t .. 1..16 ok 1 - use C4::Creators; ok 2 - use C4::Creators::PDF; ok 3 - testing new() works ok 4 - testing pdf file created ok 5 - testing Add() works ok 6 - testing Bookmark() works ok 7 - testing Compress() works ok 8 - testing Font() works ok 9 - testing FontSize() is set to 12 by default ok 10 - testing FontSize() can be set to a different value ok 11 - testing Page() works ok 12 - testing StrWidth() returns correct point width ok 13 - testing Text() writes from a given x-value ok 14 - testing Text() writes to the correct x-value ok 15 - testing End() works ok 16 - test file /tmp/4YjPQDExeS created OK ok All tests successful. Files=1, Tests=16, 1 wallclock secs ( 0.03 usr 0.01 sys + 0.48 cusr 0.05 csys = 0.57 CPU) Result: PASS Signed-off-by: Liz Rea <liz@catalyst.net.nz> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
62 lines
1.7 KiB
Perl
Executable file
62 lines
1.7 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
#
|
|
# This Koha test module is a stub!
|
|
# Add more tests here!!!
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use File::Temp qw/ tempfile /;
|
|
use Test::More tests => 16;
|
|
|
|
BEGIN {
|
|
use_ok('C4::Creators');
|
|
use_ok('C4::Creators::PDF');
|
|
}
|
|
|
|
my $pdf_creator = C4::Creators::PDF->new(InitVars => 0);
|
|
ok($pdf_creator, "testing new() works");
|
|
if (-e $pdf_creator->{filename}) {
|
|
pass('testing pdf file created');
|
|
}
|
|
else {
|
|
fail('testing pdf file created');
|
|
}
|
|
|
|
ok($pdf_creator->Add(""), "testing Add() works");
|
|
ok($pdf_creator->Bookmark({}), "testing Bookmark() works");
|
|
ok($pdf_creator->Compress(1), "testing Compress() works");
|
|
|
|
is($pdf_creator->Font("H"), "Ft1", "testing Font() works");
|
|
is($pdf_creator->FontSize(), '12', "testing FontSize() is set to 12 by default");
|
|
my @result = $pdf_creator->FontSize(14);
|
|
is($result[0], '14', "testing FontSize() can be set to a different value");
|
|
$pdf_creator->FontSize(); # Reset font size before testing text width etc below
|
|
|
|
ok($pdf_creator->Page(), "testing Page() works");
|
|
|
|
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], $expected_offset, "testing Text() writes to the correct x-value");
|
|
|
|
my ($fh, $filename) = tempfile();
|
|
open( $fh, '>', $filename );
|
|
select $fh;
|
|
|
|
ok($pdf_creator->End(), "testing End() works");
|
|
|
|
close($fh);
|
|
ok( -s $filename , "test file $filename created OK" );
|
|
unlink $filename ;
|