From 73ec0f77bf35313da54167e6e514e43bc3c3158c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 Dec 2018 14:02:14 -0300 Subject: [PATCH] Bug 21987: Add tests --- t/db_dependent/Images.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 t/db_dependent/Images.t diff --git a/t/db_dependent/Images.t b/t/db_dependent/Images.t new file mode 100644 index 0000000000..9e2e509d93 --- /dev/null +++ b/t/db_dependent/Images.t @@ -0,0 +1,39 @@ +use Modern::Perl; +use GD; +use Test::More tests => 4; + +use C4::Images; +use t::lib::TestBuilder; + +my $schema = Koha::Database->schema; +$schema->storage->txn_begin(); + +my $builder = t::lib::TestBuilder->new; +my $biblio = $builder->build_sample_biblio; + +my $path = 'koha-tmpl/intranet-tmpl/prog/img/koha-logo.png'; +my $koha_logo = GD::Image->new($path); + +{ + # True color == 0 + $koha_logo->trueColor(0); + C4::Images::PutImage( $biblio->biblionumber, $koha_logo ); + + my @imagenumbers = C4::Images::ListImagesForBiblio( $biblio->biblionumber ); + is( scalar(@imagenumbers), 1 ); + my $image = C4::Images::RetrieveImage($imagenumbers[0]); + ok( length $image->{thumbnail} < length $image->{imagefile}, 'thumbnail should be shorter than the original image' ); +} + +{ + # True color == 1 + # Note that we are cheating here, the original file is not a true color image + $koha_logo->trueColor(1); + C4::Images::PutImage( $biblio->biblionumber, $koha_logo, 'replace' ); + + my @imagenumbers = C4::Images::ListImagesForBiblio( $biblio->biblionumber ); + is( scalar(@imagenumbers), 1 ); + my $image = C4::Images::RetrieveImage($imagenumbers[0]); + ok( length $image->{thumbnail} > length $image->{imagefile}, 'thumbnail should be bigger than the original image.' ); + # Actually it should not be bigger, but we cheat with the trueColor flag +} -- 2.11.0