Bug 23078: (follow-up) Update self checkout help page
[koha.git] / t / Images.t
blob338a9030fa5dd4091550d78804d661326c4351c5
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
20 use Test::More;
21 use Test::MockModule;
23 use Module::Load::Conditional qw/check_install/;
25 BEGIN {
26 if ( check_install( module => 'Test::DBIx::Class' ) ) {
27 plan tests => 8;
28 } else {
29 plan skip_all => "Need Test::DBIx::Class"
33 use_ok('C4::Images');
35 use Test::DBIx::Class;
37 # Make the code in the module use our mocked Koha::Schema/Koha::Database
38 my $db = Test::MockModule->new('Koha::Database');
39 $db->mock(
40 # Schema() gives us the DB connection set up by Test::DBIx::Class
41 _new_schema => sub { return Schema(); }
44 my $biblionumber = 2;
45 my $images = [
46 [ 1, $biblionumber, 'gif', 'imagefile1', 'thumbnail1' ],
47 [ 3, $biblionumber, 'jpeg', 'imagefile3', 'thumbnail3' ],
49 fixtures_ok [
50 Biblioimage => [
51 [ 'imagenumber', 'biblionumber', 'mimetype', 'imagefile', 'thumbnail' ],
52 @$images,
54 ], 'add fixtures';
56 my $image = C4::Images::RetrieveImage(1);
58 is( $image->{'imagenumber'}, 1, 'First imagenumber is 1' );
60 is( $image->{'mimetype'}, 'gif', 'First mimetype is gif' );
62 is( $image->{'thumbnail'}, 'thumbnail1', 'First thumbnail is correct' );
64 my @imagenumbers = C4::Images::ListImagesForBiblio($biblionumber);
66 is( $imagenumbers[0], 1, 'imagenumber is 1' );
68 is( $imagenumbers[1], 3, 'imagenumber is 3' );
70 is( $imagenumbers[4], undef, 'imagenumber undef' );