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

(-)a/t/SocialData.t (-1 / +48 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
#Testing C4 SocialData
4
5
use strict;
6
use warnings;
7
use Test::More tests => 5;
8
use Test::MockModule;
9
10
11
12
BEGIN {
13
        use_ok('C4::SocialData');
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 $socialdata = [
22
    ['isbn','num_critics','num_critics_pro','num_quotations','num_videos','score_avg','num_scores'],
23
    ['0-596-52674-1',1,2,3,4,5.2,6],
24
    ['0-596-00289-0',2,3,4,5,6.2,7]
25
    ];
26
my $dbh = C4::Context->dbh();
27
28
$dbh->{mock_add_resultset} = $socialdata;
29
30
my $data = C4::SocialData::get_data();
31
32
is($data->{'isbn'},'0-596-52674-1', 'First isbn is 0-596-52674-1');
33
34
my $reportdata = [
35
    ['biblionumber','isbn'],
36
    [1,'0-596-52674-1'],
37
    [2,'0-596-00289-0']
38
    ];
39
40
use Data::Dumper;
41
42
$dbh->{mock_add_resultset} = $reportdata;
43
44
ok (my $report = C4::SocialData::get_report());
45
46
is ($report->{'without'}->[0]->{'original'},'0-596-52674-1', 'testing get_report gives isbn');
47
48
is ($report->{'without'}->[0]->{'isbn'},'9780596526740', 'testing get_report');

Return to bug 5327