forked from Koha-Community/Koha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImages.t
54 lines (38 loc) · 1.18 KB
/
Images.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
#
#Testing C4 Images
use strict;
use warnings;
use Test::More tests => 7;
use Test::MockModule;
BEGIN {
use_ok('C4::Images');
}
my $module = new Test::MockModule('C4::Context');
$module->mock(
'_new_dbh',
sub {
my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
|| die "Cannot create handle: $DBI::errstr\n";
return $dbh;
}
);
my $images = [
[ 'imagenumber', 'biblionumber', 'mimetype', 'imagefile', 'thumbnail' ],
[ 1, 2, 'gif', 'red', 001, 000 ],
[ 3, 2, 'jpeg', 'blue', 111, 110 ]
];
my $dbh = C4::Context->dbh();
$dbh->{mock_add_resultset} = $images;
my $image = C4::Images::RetrieveImage();
is( $image->{'imagenumber'}, 1, 'First imagenumber is 1' );
is( $image->{'mimetype'}, 'gif', 'First mimetype is red' );
is( $image->{'thumbnail'}, 001, 'First thumbnail is 001' );
$image = C4::Images::RetrieveImage();
$image = C4::Images::RetrieveImage();
$dbh->{mock_add_resultset} = $images;
my @imagenumbers = C4::Images::ListImagesForBiblio();
is( $imagenumbers[0], 1, 'imagenumber is 1' );
is( $imagenumbers[1], 3, 'imagenumber is 3' );
$dbh->{mock_add_resultset} = $images;
is( $imagenumbers[4], undef, 'imagenumber undef' );