Bug 23420: (QA follow-up) Remove AllowPurchaseSuggestionBranchChoice syspref
[koha.git] / t / SocialData.t
blobdf14a50132ba48de978ff78bb0151387b40a0883
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;
39 fixtures_ok [
40 Biblioitem => [
41 ['biblionumber', 'isbn'],
42 [1, '0-596-52674-1'],
43 [2, '0-596-00289-0'],
45 SocialData => [
47 'isbn', 'num_critics',
48 'num_critics_pro', 'num_quotations',
49 'num_videos', 'score_avg',
50 'num_scores'
52 [ '0-596-52674-1', 1, 2, 3, 4, 5.2, 6 ],
53 [ '0-596-00289-0', 2, 3, 4, 5, 6.2, 7 ]
55 ], 'add fixtures';
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' );