Bug 13173 - remove some operations that are no longer needed
[koha.git] / t / Images.t
blobc35d5bd44309e0cee6e9a78422dd210d62917d01
1 #!/usr/bin/perl
3 #Testing C4 Images
5 use strict;
6 use warnings;
7 use Test::More tests => 7;
8 use Test::MockModule;
10 BEGIN {
11 use_ok('C4::Images');
14 my $module = new Test::MockModule('C4::Context');
15 $module->mock(
16 '_new_dbh',
17 sub {
18 my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
19 || die "Cannot create handle: $DBI::errstr\n";
20 return $dbh;
23 my $images = [
24 [ 'imagenumber', 'biblionumber', 'mimetype', 'imagefile', 'thumbnail' ],
25 [ 1, 2, 'gif', 'red', 001, 000 ],
26 [ 3, 2, 'jpeg', 'blue', 111, 110 ]
28 my $dbh = C4::Context->dbh();
30 $dbh->{mock_add_resultset} = $images;
32 my $image = C4::Images::RetrieveImage();
34 is( $image->{'imagenumber'}, 1, 'First imagenumber is 1' );
36 is( $image->{'mimetype'}, 'gif', 'First mimetype is red' );
38 is( $image->{'thumbnail'}, 001, 'First thumbnail is 001' );
40 $image = C4::Images::RetrieveImage();
42 $image = C4::Images::RetrieveImage();
44 $dbh->{mock_add_resultset} = $images;
46 my @imagenumbers = C4::Images::ListImagesForBiblio();
48 is( $imagenumbers[0], 1, 'imagenumber is 1' );
50 is( $imagenumbers[1], 3, 'imagenumber is 3' );
52 $dbh->{mock_add_resultset} = $images;
54 is( $imagenumbers[4], undef, 'imagenumber undef' );