From 51dd295dfa6c2a4e827d6b8061da62194a952254 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 5 Jul 2013 14:54:51 +0200 Subject: [PATCH] =?utf8?q?Tests:=20Test-Case=20f=C3=BCr=20g=C3=BCltige=20M?= =?utf8?q?ethodennamen=20auf=20$::instance=5Fconf?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- t/structure/instance_conf_method_names.t | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 t/structure/instance_conf_method_names.t diff --git a/t/structure/instance_conf_method_names.t b/t/structure/instance_conf_method_names.t new file mode 100755 index 000000000..e442fa6f3 --- /dev/null +++ b/t/structure/instance_conf_method_names.t @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +use strict; +use lib 't'; +use File::Find; +use File::Slurp; +use Test::More; + +my %default_columns; + +sub read_default_columns { + my $content = read_file('SL/DB/MetaSetup/Default.pm'); + my ($columns) = $content =~ m{\n__PACKAGE__->meta->columns\((.+?)\n\)}s; + $columns =~ s/=>.*?\},|\n//g; + $columns =~ s/ +/ /g; + $columns =~ s/^\s+|\s+$//g; + + return map { ($_ => 1) } split m/ +/, $columns; +} + +sub test_file_content { + my ($file) = @_; + my $content = read_file($file); + + while ($content =~ m{(?:INSTANCE_CONF\.|\$(?:main)?::instance_conf->)get_([a-z0-9_]+)}gi) { + ok($default_columns{$1}, "'get_${1}' is a valid method call on \$::instance_conf in $file"); + } +} + +%default_columns = read_default_columns(); +my @files = glob('*.pl'); +find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/; }, 'SL'); +find(sub { push(@files, $File::Find::name) if $_ =~ /\.pl$/; }, qw(bin/mozilla sql/Pg-upgrade2 scripts)); +find(sub { push(@files, $File::Find::name) if $_ =~ /\.html$/; }, 'templates/webpages'); + +test_file_content($_) for @files; + +done_testing(); -- 2.20.1