From: Moritz Bunkus Date: Fri, 5 Jul 2013 12:54:51 +0000 (+0200) Subject: Tests: Test-Case für gültige Methodennamen auf $::instance_conf X-Git-Tag: release-3.1.0beta1~205 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=51dd295dfa6c2a4e827d6b8061da62194a952254;p=kivitendo-erp.git Tests: Test-Case für gültige Methodennamen auf $::instance_conf --- 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();