Bug 9032: (follow-up) add support for bootstrap theme
[koha.git] / t / db_dependent / Csv.t
blobbe42e8a9160c809986b01477a41948886ab0aa38
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More tests => 10;
7 use Test::Deep;
9 use C4::Context;
10 BEGIN {
11 use_ok('C4::Csv');
14 my $dbh = C4::Context->dbh;
15 $dbh->{AutoCommit} = 0;
16 $dbh->{RaiseError} = 1;
18 $dbh->do('DELETE FROM export_format');
20 my $sth = $dbh->prepare(q{
21 INSERT INTO export_format (profile, description, content, type)
22 VALUES (?, ?, ?, ?)
23 });
24 $sth->execute('MARC', 'MARC profile', '245$a', 'marc');
25 $sth->execute('SQL', 'SQL profile', 'borrowers.surname', 'sql');
27 my $all_profiles = C4::Csv::GetCsvProfiles();
28 is(@$all_profiles, 2, 'test getting all CSV profiles');
30 my $sql_profiles = C4::Csv::GetCsvProfiles('sql');
31 is(@$sql_profiles, 1, 'test getting SQL CSV profiles');
32 is($sql_profiles->[0]->{profile}, 'SQL', '... and got the right one');
33 my $marc_profiles = C4::Csv::GetCsvProfiles('marc');
34 is(@$marc_profiles, 1, 'test getting MARC CSV profiles');
35 is($marc_profiles->[0]->{profile}, 'MARC', '... and got the right one');
37 my $id = C4::Csv::GetCsvProfileId('MARC');
38 my $profile = C4::Csv::GetCsvProfile($id);
39 is($profile->{profile}, 'MARC', 'retrieved profile by ID');
41 is(C4::Csv::GetCsvProfile(), undef, 'test getting CSV profile but not supplying ID');
43 cmp_deeply(
44 C4::Csv::GetCsvProfilesLoop(),
47 export_format_id => ignore(),
48 profile => 'MARC',
51 export_format_id => ignore(),
52 profile => 'SQL',
55 'test getting profile loop'
58 cmp_deeply(
59 C4::Csv::GetCsvProfilesLoop('marc'),
62 export_format_id => ignore(),
63 profile => 'MARC',
66 'test getting profile loop for one type'