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>.
23 use Module
::Load
::Conditional qw
/check_install/;
26 if ( check_install
( module
=> 'Test::DBIx::Class' ) ) {
29 plan skip_all
=> "Need Test::DBIx::Class"
34 use_ok
('C4::SocialData');
37 use Test
::DBIx
::Class
;
41 ['biblionumber', 'isbn'],
47 'isbn', 'num_critics',
48 'num_critics_pro', 'num_quotations',
49 'num_videos', 'score_avg',
52 [ '0-596-52674-1', 1, 2, 3, 4, 5.2, 6 ],
53 [ '0-596-00289-0', 2, 3, 4, 5, 6.2, 7 ]
57 my $db = Test
::MockModule
->new('Koha::Database');
58 $db->mock( _new_schema
=> sub { return Schema
(); } );
59 Koha
::Database
::flush_schema_cache
();
61 my $data = C4
::SocialData
::get_data
();
62 is
( $data, undef, 'get_data should return undef if no param given');
64 $data = C4
::SocialData
::get_data
('0-596-52674-1');
65 is
( $data->{isbn
}, '0-596-52674-1', 'get_data should return the matching row');
67 my $report = C4
::SocialData
::get_report
('0-596-52674-1');
69 is
( $report->{'without'}->[0]->{'original'},
70 '0-596-52674-1', 'testing get_report gives isbn' );
72 is
( $report->{'without'}->[0]->{'isbn'}, '9780596526740',
73 'testing get_report' );