Revert "Bug 14598 [QA Followup] - Make unit test pass"
[koha.git] / t / SocialData.t
blob8b6a93b2686b6a0cab8b1b55797ba2113a40d950
1 #!/usr/bin/perl
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>.
18 use Modern::Perl;
20 use Test::More;
21 use Test::MockModule;
23 use Module::Load::Conditional qw/check_install/;
25 BEGIN {
26 if ( check_install( module => 'Test::DBIx::Class' ) ) {
27 plan tests => 6;
28 } else {
29 plan skip_all => "Need Test::DBIx::Class"
33 BEGIN {
34 use_ok('C4::SocialData');
37 use Test::DBIx::Class {
38 schema_class => 'Koha::Schema',
39 connect_info => ['dbi:SQLite:dbname=:memory:','',''],
40 connect_opts => { name_sep => '.', quote_char => '`', },
41 fixture_class => '::Populate',
42 }, 'SocialData', 'Biblioitem' ;
44 fixtures_ok [
45 Biblioitem => [
46 ['biblionumber', 'isbn'],
47 [1, '0-596-52674-1'],
48 [2, '0-596-00289-0'],
50 SocialData => [
52 'isbn', 'num_critics',
53 'num_critics_pro', 'num_quotations',
54 'num_videos', 'score_avg',
55 'num_scores'
57 [ '0-596-52674-1', 1, 2, 3, 4, 5.2, 6 ],
58 [ '0-596-00289-0', 2, 3, 4, 5, 6.2, 7 ]
60 ], 'add fixtures';
62 my $db = Test::MockModule->new('Koha::Database');
63 $db->mock( _new_schema => sub { return Schema(); } );
65 my $data = C4::SocialData::get_data();
66 is( $data, undef, 'get_data should return undef if no param given');
68 $data = C4::SocialData::get_data('0-596-52674-1');
69 is( $data->{isbn}, '0-596-52674-1', 'get_data should return the matching row');
71 my $report = C4::SocialData::get_report('0-596-52674-1');
73 is( $report->{'without'}->[0]->{'original'},
74 '0-596-52674-1', 'testing get_report gives isbn' );
76 is( $report->{'without'}->[0]->{'isbn'}, '9780596526740',
77 'testing get_report' );