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

(-)a/t/db_dependent/check_sysprefs.t (-1 / +33 lines)
Lines 44-49 if ( !$showsql ) { Link Here
44
44
45
check_db($ref_syspref);
45
check_db($ref_syspref);
46
46
47
subtest 'Ensure a preference in .pref file exists in sysprefs.sql' => sub {
48
    my @file_preferences = get_prefs_from_pref_files();
49
    my $sysprefs = $ref_syspref;
50
    plan tests => 1;
51
52
    my @missing_prefs;
53
    foreach my $pref (@file_preferences) {
54
        push @missing_prefs, $pref unless $sysprefs->{$pref};
55
    }
56
57
    is(join(', ',@missing_prefs), '',
58
       'No preferences are missing from database');
59
};
60
47
#
61
#
48
# Get sysprefs from SQL file populating sysprefs table with INSERT statement.
62
# Get sysprefs from SQL file populating sysprefs table with INSERT statement.
49
#
63
#
Lines 101-106 sub check_db { Link Here
101
    }
115
    }
102
}
116
}
103
117
118
sub get_prefs_from_pref_files {
119
    my $intratmpl = C4::Context->config('intrahtdocs');
120
    my $dir = "$intratmpl/prog/en/modules/admin/preferences";
121
    my @file_preferences;
122
    foreach my $fp (glob("$dir/*.pref")) {
123
        open my $fh, "<", $fp or die "can't read open '$fp'";
124
        while (<$fh>) {
125
            if ($_ =~ /^(?!#).*pref: .*\n/) {
126
                my $pref = $_;
127
                $pref =~ s/"|'//g;       # remove " and '
128
                $pref =~ s/^\s*- pref:\s//; # remove "- pref:"
129
                $pref =~ s/^\s+|\s+$//g; # trim
130
                push @file_preferences, $pref;
131
            }
132
        }
133
        close $fh or die "can't read close '$fp'";
134
    }
135
    return sort @file_preferences;
136
}
104
=head1 NAME
137
=head1 NAME
105
138
106
syspref.t
139
syspref.t
107
- 

Return to bug 18446