View | Details | Raw Unified | Return to bug 5327
Collapse All | Expand All

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

Return to bug 5327