Bugzilla – Attachment 62298 Details for
Bug 18446
Test to ensure a system preference in .pref file also exists in sysprefs.sql
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18446: Compare preferences in .pref files to sysprefs.sql
Bug-18446-Compare-preferences-in-pref-files-to-sys.patch (text/plain), 2.05 KB, created by
Lari Taskula
on 2017-04-18 14:38:22 UTC
(
hide
)
Description:
Bug 18446: Compare preferences in .pref files to sysprefs.sql
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2017-04-18 14:38:22 UTC
Size:
2.05 KB
patch
obsolete
>From 8dae35dc69631f91f8c891ad9b793476e7f3c18a Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Tue, 18 Apr 2017 14:35:22 +0000 >Subject: [PATCH] Bug 18446: Compare preferences in .pref files to sysprefs.sql > >This patch adds a test that reads system preferences from .pref files and checks >that they are also defined in sysprefs.sql. > >To test: >1. prove t/db_dependent/check_sysprefs.t >--- > t/db_dependent/check_sysprefs.t | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > >diff --git a/t/db_dependent/check_sysprefs.t b/t/db_dependent/check_sysprefs.t >index b179c4a..880967e 100755 >--- a/t/db_dependent/check_sysprefs.t >+++ b/t/db_dependent/check_sysprefs.t >@@ -44,6 +44,20 @@ if ( !$showsql ) { > > check_db($ref_syspref); > >+subtest 'Ensure a preference in .pref file exists in sysprefs.sql' => sub { >+ my @file_preferences = get_prefs_from_pref_files(); >+ my $sysprefs = $ref_syspref; >+ plan tests => 1; >+ >+ my @missing_prefs; >+ foreach my $pref (@file_preferences) { >+ push @missing_prefs, $pref unless $sysprefs->{$pref}; >+ } >+ >+ is(join(', ',@missing_prefs), '', >+ 'No preferences are missing from database'); >+}; >+ > # > # Get sysprefs from SQL file populating sysprefs table with INSERT statement. > # >@@ -101,6 +115,25 @@ sub check_db { > } > } > >+sub get_prefs_from_pref_files { >+ my $intratmpl = C4::Context->config('intrahtdocs'); >+ my $dir = "$intratmpl/prog/en/modules/admin/preferences"; >+ my @file_preferences; >+ foreach my $fp (glob("$dir/*.pref")) { >+ open my $fh, "<", $fp or die "can't read open '$fp'"; >+ while (<$fh>) { >+ if ($_ =~ /^(?!#).*pref: .*\n/) { >+ my $pref = $_; >+ $pref =~ s/"|'//g; # remove " and ' >+ $pref =~ s/^\s*- pref:\s//; # remove "- pref:" >+ $pref =~ s/^\s+|\s+$//g; # trim >+ push @file_preferences, $pref; >+ } >+ } >+ close $fh or die "can't read close '$fp'"; >+ } >+ return sort @file_preferences; >+} > =head1 NAME > > syspref.t >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18446
: 62298