Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 51dd295d

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 51dd295dfa6c2a4e827d6b8061da62194a952254
  • Vorgänger d5aaeae1
  • Nachfolger 5527271d

Tests: Test-Case für gültige Methodennamen auf $::instance_conf

Unterschiede anzeigen:

t/structure/instance_conf_method_names.t
1
#!/usr/bin/perl
2

  
3
use strict;
4
use lib 't';
5
use File::Find;
6
use File::Slurp;
7
use Test::More;
8

  
9
my %default_columns;
10

  
11
sub read_default_columns {
12
  my $content   =  read_file('SL/DB/MetaSetup/Default.pm');
13
  my ($columns) =  $content =~ m{\n__PACKAGE__->meta->columns\((.+?)\n\)}s;
14
  $columns      =~ s/=>.*?\},|\n//g;
15
  $columns      =~ s/ +/ /g;
16
  $columns      =~ s/^\s+|\s+$//g;
17

  
18
  return map { ($_ => 1) } split m/ +/, $columns;
19
}
20

  
21
sub test_file_content {
22
  my ($file)  = @_;
23
  my $content = read_file($file);
24

  
25
  while ($content =~ m{(?:INSTANCE_CONF\.|\$(?:main)?::instance_conf->)get_([a-z0-9_]+)}gi) {
26
    ok($default_columns{$1}, "'get_${1}' is a valid method call on \$::instance_conf in $file");
27
  }
28
}
29

  
30
%default_columns = read_default_columns();
31
my @files        = glob('*.pl');
32
find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;   }, 'SL');
33
find(sub { push(@files, $File::Find::name) if $_ =~ /\.pl$/;   },  qw(bin/mozilla sql/Pg-upgrade2 scripts));
34
find(sub { push(@files, $File::Find::name) if $_ =~ /\.html$/; }, 'templates/webpages');
35

  
36
test_file_content($_) for @files;
37

  
38
done_testing();

Auch abrufbar als: Unified diff