Bugzilla – Attachment 111449 Details for
Bug 26145
Add the ability to attach a cover image at item level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26145: Refactoring - Add tests
Bug-26145-Refactoring---Add-tests.patch (text/plain), 3.71 KB, created by
Katrin Fischer
on 2020-10-11 12:50:46 UTC
(
hide
)
Description:
Bug 26145: Refactoring - Add tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-10-11 12:50:46 UTC
Size:
3.71 KB
patch
obsolete
>From 8cf2cd64c4c127737af84dc4fa9da7e47efcc933 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 29 Jul 2020 18:29:03 +0200 >Subject: [PATCH] Bug 26145: Refactoring - Add tests > >Sponsored-by: Gerhard Sondermann Dialog e.K. (presseplus.de, presseshop.at, presseshop.ch) > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/Koha/CoverImages.t | 96 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 96 insertions(+) > create mode 100644 t/db_dependent/Koha/CoverImages.t > >diff --git a/t/db_dependent/Koha/CoverImages.t b/t/db_dependent/Koha/CoverImages.t >new file mode 100644 >index 0000000000..69cfdf405a >--- /dev/null >+++ b/t/db_dependent/Koha/CoverImages.t >@@ -0,0 +1,96 @@ >+#!/usr/bin/perl >+ >+# Copyright 2020 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 13; >+use Test::Exception; >+ >+use FindBin '$Bin'; >+ >+use Koha::CoverImages; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+ >+my $biblio = $builder->build_sample_biblio; >+my $item = $builder->build_sample_item; >+ >+is( $biblio->cover_images->count, 0, 'No cover images yet' ); >+ >+my $no_image = Koha::CoverImages->no_image; >+is( ref($no_image), 'Koha::CoverImage', >+ 'no_image returns a Koha::CoverImage object' ); >+is( $no_image->mimetype, 'image/gif', 'no_image is a gif image' ); >+ok( $no_image->imagefile, 'no_image has imagefile set' ); >+ok( $no_image->thumbnail, 'no_image has thumbnail set' ); >+ >+my $logo_filepath = >+ "$Bin/../../../koha-tmpl/intranet-tmpl/prog/img/koha-logo.png"; >+my $image = Koha::CoverImage->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ src_image => GD::Image->new($logo_filepath) >+ } >+)->store; >+ >+is( $biblio->cover_images->count, 1, 'There is one cover image' ); >+my $cover_image = $biblio->cover_images->next; >+ok( $cover_image->imagefile, 'image is stored in imagefile' ); >+ok( $cover_image->thumbnail, 'thumbnail has been generated' ); >+is( $cover_image->mimetype, 'image/png', >+ 'mimetype has been correctly guessed' ); >+ >+$image = Koha::CoverImage->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ src_image => GD::Image->new($logo_filepath) >+ } >+)->store; >+is( $biblio->cover_images->count, 2, 'There are now two cover images' ); >+ >+is( $item->cover_image, undef, 'No cover images yet' ); >+$image = Koha::CoverImage->new( >+ { >+ itemnumber => $item->itemnumber, >+ src_image => GD::Image->new($logo_filepath) >+ } >+)->store; >+is( ref( $item->cover_image ), >+ 'Koha::CoverImage', >+ 'Koha::Item->cover_image returns a Koha::CoverImage object' ); >+ >+throws_ok { >+ Koha::CoverImage->new( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item->itemnumber, >+ src_image => GD::Image->new($logo_filepath) >+ } >+ )->store >+} >+'Koha::Exceptions::WrongParameter', >+ 'Exception is thrown if both biblionumber and itemnumber are passed'; >+ >+$schema->storage->txn_rollback; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26145
:
109225
|
109226
|
110342
|
110343
|
110344
|
110345
|
110346
|
110347
|
110348
|
110349
|
110350
|
110351
|
110352
|
110353
|
110354
|
110675
|
110676
|
110677
|
110678
|
110679
|
110680
|
110681
|
110682
|
110683
|
110684
|
110685
|
110800
|
110861
|
110862
|
110863
|
110864
|
110865
|
110866
|
110867
|
110868
|
110869
|
110870
|
110871
|
110872
|
110873
|
110874
|
110875
|
111446
|
111447
|
111448
| 111449 |
111450
|
111451
|
111452
|
111453
|
111454
|
111455
|
111456
|
111457
|
111458