Bugzilla – Attachment 10748 Details for
Bug 8353
Add test to compare system preferences in db to syspref.sql
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8353 follow-up, perltidy
Bug-8353-follow-up-perltidy.patch (text/plain), 3.79 KB, created by
Paul Poulain
on 2012-07-10 14:33:57 UTC
(
hide
)
Description:
Bug 8353 follow-up, perltidy
Filename:
MIME Type:
Creator:
Paul Poulain
Created:
2012-07-10 14:33:57 UTC
Size:
3.79 KB
patch
obsolete
>From 2741468153c9f1e600f27e98dd7369689a6ccb78 Mon Sep 17 00:00:00 2001 >From: Paul Poulain <paul.poulain@biblibre.com> >Date: Tue, 10 Jul 2012 16:01:38 +0200 >Subject: [PATCH] Bug 8353 follow-up, perltidy > >It's a new script, perltidy-ing it before pushing >--- > xt/check_sysprefs.t | 65 ++++++++++++++++++++++----------------------------- > 1 file changed, 28 insertions(+), 37 deletions(-) > >diff --git a/xt/check_sysprefs.t b/xt/check_sysprefs.t >index d76cdb9..f7fc914 100755 >--- a/xt/check_sysprefs.t >+++ b/xt/check_sysprefs.t >@@ -23,32 +23,26 @@ use warnings; > use Getopt::Long; > use C4::Context; > >- > # When this option is set, no tests are performed. > # The missing sysprefs are displayed as sql inserts instead. > our $showsql = 0; >-GetOptions ('showsql' => \$showsql); >- >+GetOptions( 'showsql' => \$showsql ); > > use Test::More qw(no_plan); >-our $dbh = C4::Context->dbh; >-my $root_dir = C4::Context->config( 'intranetdir' ) . '/installer/data/mysql'; >+our $dbh = C4::Context->dbh; >+my $root_dir = C4::Context->config('intranetdir') . '/installer/data/mysql'; > my $base_syspref_file = "sysprefs.sql"; > >- > open( my $ref_fh, "<$root_dir/$base_syspref_file" ); >-my $ref_syspref = get_syspref_from_file( $ref_fh ); >+my $ref_syspref = get_syspref_from_file($ref_fh); > my @ref_sysprefs = sort { lc $a cmp lc $b } keys %$ref_syspref; >-if (!$showsql) { >- cmp_ok( >- $#ref_sysprefs, '>=', 0, >- "Found " . ($#ref_sysprefs + 1) . " sysprefs" >- ); >+if ( !$showsql ) { >+ cmp_ok( $#ref_sysprefs, '>=', 0, >+ "Found " . ( $#ref_sysprefs + 1 ) . " sysprefs" ); > } > > check_db($ref_syspref); > >- > # > # Get sysprefs from SQL file populating sysprefs table with INSERT statement. > # >@@ -60,10 +54,10 @@ check_db($ref_syspref); > sub get_syspref_from_file { > my $fh = shift; > my %syspref; >- while ( <$fh> ) { >- next if /^--/; # Comment line >+ while (<$fh>) { >+ next if /^--/; # Comment line > my $query = $_; >- if ($_ =~ /\([\s]*\'([\w\-:]+)\'/) { >+ if ( $_ =~ /\([\s]*\'([\w\-:]+)\'/ ) { > my $variable = $1; > if ($variable) { > $syspref{$variable} = $query; >@@ -73,42 +67,39 @@ sub get_syspref_from_file { > return \%syspref; > } > >- > sub check_db { > my $sysprefs = shift; > > # Checking the number of sysprefs in the database > my $query = "SELECT COUNT(*) FROM systempreferences"; >- my $sth = $dbh->prepare($query); >+ my $sth = $dbh->prepare($query); > $sth->execute; >- my $res = $sth->fetchrow_arrayref; >+ my $res = $sth->fetchrow_arrayref; > my $dbcount = $res->[0]; >- if (!$showsql) { >- cmp_ok ( >- $dbcount, ">=", scalar(keys %$sysprefs), "There are at least as many sysprefs in the database as in the sysprefs.sql" >- ); >+ if ( !$showsql ) { >+ cmp_ok( $dbcount, ">=", scalar( keys %$sysprefs ), >+"There are at least as many sysprefs in the database as in the sysprefs.sql" >+ ); > } > > # Checking for missing sysprefs in the database > $query = "SELECT COUNT(*) FROM systempreferences WHERE variable=?"; >- $sth = $dbh->prepare($query); >- foreach (keys %$sysprefs) { >- $sth->execute($_); >- my $res = $sth->fetchrow_arrayref; >- my $count = $res->[0]; >- if (!$showsql) { >- is( >- $count, 1, "Syspref $_ exists in the database" >- ); >- } else { >- if ($count != 1) { >- print $sysprefs->{$_}; >+ $sth = $dbh->prepare($query); >+ foreach ( keys %$sysprefs ) { >+ $sth->execute($_); >+ my $res = $sth->fetchrow_arrayref; >+ my $count = $res->[0]; >+ if ( !$showsql ) { >+ is( $count, 1, "Syspref $_ exists in the database" ); >+ } >+ else { >+ if ( $count != 1 ) { >+ print $sysprefs->{$_}; >+ } > } >- } > } > } > >- > =head1 NAME > > syspref.t >-- >1.7.9.5
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 8353
:
10628
|
10748
|
10813
|
10814
|
10815
|
10816