Revision 1d91e75c
Von Sven Schöling vor mehr als 15 Jahren hinzugefügt
t/001compile.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla Tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Zach Lipton
|
||
# Portions created by Zach Lipton are
|
||
# Copyright (C) 2001 Zach Lipton. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Zach Lipton <zach@zachlipton.com>
|
||
|
||
|
||
#################
|
||
#Bugzilla Test 1#
|
||
###Compilation###
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
use lib '../modules/override';
|
||
use lib '../modules/fallback';
|
||
|
||
use Support::Files;
|
||
|
||
use Test::More tests => scalar(@Support::Files::testitems);
|
||
|
||
# Need this to get the available driver information
|
||
use DBI;
|
||
my @DBI_drivers = DBI->available_drivers;
|
||
|
||
# Bugzilla requires Perl 5.8.0 now. Checksetup will tell you this if you run it, but
|
||
# it tests it in a polite/passive way that won't make it fail at compile time. We'll
|
||
# slip in a compile-time failure if it's missing here so a tinderbox on < 5.8 won't
|
||
# pass and mistakenly let people think Bugzilla works on any perl below 5.8.
|
||
require 5.008;
|
||
|
||
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
|
||
# This will handle verbosity for us automatically.
|
||
my $fh;
|
||
{
|
||
local $^W = 0; # Don't complain about non-existent filehandles
|
||
if (-e \*Test::More::TESTOUT) {
|
||
$fh = \*Test::More::TESTOUT;
|
||
} elsif (-e \*Test::Builder::TESTOUT) {
|
||
$fh = \*Test::Builder::TESTOUT;
|
||
} else {
|
||
$fh = \*STDOUT;
|
||
}
|
||
}
|
||
|
||
my @testitems = @Support::Files::testitems;
|
||
my $perlapp = "\"$^X\"";
|
||
|
||
# Test the scripts by compiling them
|
||
|
||
foreach my $file (@testitems) {
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
|
||
# Skip mod_perl.pl in all cases. It doesn't compile correctly from the command line.
|
||
if ($file eq 'mod_perl.pl') {
|
||
ok(1, "Skipping mod_perl.pl");
|
||
next;
|
||
}
|
||
|
||
# Check that we have a DBI module to support the DB, if this is a database
|
||
# module (but not Schema)
|
||
if ($file =~ m#Bugzilla/DB/([^/]+)\.pm$# && $file ne "Bugzilla/DB/Schema.pm") {
|
||
if (!grep(lc($_) =~ /$1/i, @DBI_drivers)) {
|
||
ok(1,$file." - Skipping, as the DBD module not installed");
|
||
next;
|
||
}
|
||
}
|
||
|
||
open (FILE,$file);
|
||
my $bang = <FILE>;
|
||
close (FILE);
|
||
my $T = "";
|
||
if ($bang =~ m/#!\S*perl\s+-.*T/) {
|
||
$T = "T";
|
||
}
|
||
my $command = "$perlapp -c$T -I modules/fallback -I modules/override $file 2>&1";
|
||
my $loginfo=`$command`;
|
||
#print '@@'.$loginfo.'##';
|
||
if ($loginfo =~ /syntax ok$/im) {
|
||
if ($loginfo ne "$file syntax OK\n") {
|
||
ok(0,$file." --WARNING");
|
||
print $fh $loginfo;
|
||
} else {
|
||
ok(1,$file);
|
||
}
|
||
} else {
|
||
ok(0,$file." --ERROR");
|
||
print $fh $loginfo;
|
||
}
|
||
}
|
||
|
||
exit 0;
|
t/002goodperl.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla Tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Zach Lipton
|
||
# Portions created by Zach Lipton are
|
||
# Copyright (C) 2001 Zach Lipton. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Zach Lipton <zach@zachlipton.com>
|
||
# Jacob Steenhagen <jake@bugzilla.org>
|
||
# David D. Kilzer <ddkilzer@theracingworld.com>
|
||
|
||
|
||
#################
|
||
#Bugzilla Test 2#
|
||
####GoodPerl#####
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
|
||
use Support::Files;
|
||
|
||
use Test::More tests => (scalar(@Support::Files::testitems) * 3);
|
||
|
||
my @testitems = @Support::Files::testitems; # get the files to test.
|
||
|
||
foreach my $file (@testitems) {
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
if (! open (FILE, $file)) {
|
||
ok(0,"could not open $file --WARNING");
|
||
}
|
||
my $file_line1 = <FILE>;
|
||
close (FILE);
|
||
|
||
$file =~ m/.*\.(.*)/;
|
||
my $ext = $1;
|
||
|
||
if ($file_line1 !~ m/^#\!/) {
|
||
ok(1,"$file does not have a shebang");
|
||
} else {
|
||
my $flags;
|
||
if (!defined $ext || $ext eq "pl") {
|
||
# standalone programs aren't taint checked yet
|
||
$flags = "w";
|
||
} elsif ($ext eq "pm") {
|
||
ok(0, "$file is a module, but has a shebang");
|
||
next;
|
||
} elsif ($ext eq "cgi") {
|
||
# cgi files must be taint checked
|
||
$flags = "wT";
|
||
} else {
|
||
ok(0, "$file has shebang but unknown extension");
|
||
next;
|
||
}
|
||
|
||
if ($file_line1 =~ m#^\#\!/usr/bin/perl\s#) {
|
||
if ($file_line1 =~ m#\s-$flags#) {
|
||
ok(1,"$file uses standard perl location and -$flags");
|
||
} else {
|
||
ok(0,"$file is MISSING -$flags --WARNING");
|
||
}
|
||
} else {
|
||
ok(0,"$file uses non-standard perl location");
|
||
}
|
||
}
|
||
}
|
||
|
||
foreach my $file (@testitems) {
|
||
my $found_use_strict = 0;
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
if (! open (FILE, $file)) {
|
||
ok(0,"could not open $file --WARNING");
|
||
next;
|
||
}
|
||
while (my $file_line = <FILE>) {
|
||
if ($file_line =~ m/^\s*use strict/) {
|
||
$found_use_strict = 1;
|
||
last;
|
||
}
|
||
}
|
||
close (FILE);
|
||
if ($found_use_strict) {
|
||
ok(1,"$file uses strict");
|
||
} else {
|
||
ok(0,"$file DOES NOT use strict --WARNING");
|
||
}
|
||
}
|
||
|
||
# Check to see that all error messages use tags (for l10n reasons.)
|
||
foreach my $file (@testitems) {
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
if (! open (FILE, $file)) {
|
||
ok(0,"could not open $file --WARNING");
|
||
next;
|
||
}
|
||
my $lineno = 0;
|
||
my $error = 0;
|
||
|
||
while (!$error && (my $file_line = <FILE>)) {
|
||
$lineno++;
|
||
if ($file_line =~ /Throw.*Error\("(.*?)"/) {
|
||
if ($1 =~ /\s/) {
|
||
ok(0,"$file has a Throw*Error call on line $lineno which doesn't use a tag --ERROR");
|
||
$error = 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
ok(1,"$file uses Throw*Error calls correctly") if !$error;
|
||
|
||
close(FILE);
|
||
}
|
||
|
||
exit 0;
|
t/003safesys.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla Tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Zach Lipton
|
||
# Portions created by Zach Lipton are
|
||
# Copyright (C) 2001 Zach Lipton. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Zach Lipton <zach@zachlipton.com>
|
||
|
||
|
||
#################
|
||
#Bugzilla Test 3#
|
||
###Safesystem####
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
|
||
use Support::Files;
|
||
|
||
use Test::More tests => scalar(@Support::Files::testitems);
|
||
|
||
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
|
||
# This will handle verbosity for us automatically.
|
||
my $fh;
|
||
{
|
||
local $^W = 0; # Don't complain about non-existent filehandles
|
||
if (-e \*Test::More::TESTOUT) {
|
||
$fh = \*Test::More::TESTOUT;
|
||
} elsif (-e \*Test::Builder::TESTOUT) {
|
||
$fh = \*Test::Builder::TESTOUT;
|
||
} else {
|
||
$fh = \*STDOUT;
|
||
}
|
||
}
|
||
|
||
my @testitems = @Support::Files::testitems;
|
||
my $perlapp = "\"$^X\"";
|
||
|
||
foreach my $file (@testitems) {
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1";
|
||
my $loginfo=`$command`;
|
||
if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) {
|
||
ok(0,"$file DOES NOT use proper system or exec calls");
|
||
print $fh $loginfo;
|
||
} else {
|
||
ok(1,"$file uses proper system and exec calls");
|
||
}
|
||
}
|
||
|
||
exit 0;
|
t/004template.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Jacob Steenhagen.
|
||
# Portions created by Jacob Steenhagen are
|
||
# Copyright (C) 2001 Jacob Steenhagen. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
|
||
# Zach Lipton <zach@zachlipton.com>
|
||
# David D. Kilzer <ddkilzer@kilzer.net>
|
||
# Tobias Burnus <burnus@net-b.de>
|
||
#
|
||
|
||
#################
|
||
#Bugzilla Test 4#
|
||
####Templates####
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
|
||
use Support::Templates;
|
||
|
||
# Bug 137589 - Disable command-line input of CGI.pm when testing
|
||
use CGI qw(-no_debug);
|
||
|
||
use File::Spec;
|
||
use Template;
|
||
use Test::More tests => ( scalar(@referenced_files) * scalar(@languages)
|
||
+ $num_actual_files );
|
||
|
||
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
|
||
# This will handle verbosity for us automatically.
|
||
my $fh;
|
||
{
|
||
local $^W = 0; # Don't complain about non-existent filehandles
|
||
if (-e \*Test::More::TESTOUT) {
|
||
$fh = \*Test::More::TESTOUT;
|
||
} elsif (-e \*Test::Builder::TESTOUT) {
|
||
$fh = \*Test::Builder::TESTOUT;
|
||
} else {
|
||
$fh = \*STDOUT;
|
||
}
|
||
}
|
||
|
||
# Checks whether one of the passed files exists
|
||
sub existOnce {
|
||
foreach my $file (@_) {
|
||
return $file if -e $file;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
# Check to make sure all templates that are referenced in
|
||
# Bugzilla exist in the proper place.
|
||
|
||
foreach my $lang (@languages) {
|
||
foreach my $file (@referenced_files) {
|
||
my @path = map(File::Spec->catfile($_, $file),
|
||
split(':', $include_path{$lang} . ":" . $include_path{"en"}));
|
||
if (my $path = existOnce(@path)) {
|
||
ok(1, "$path exists");
|
||
} else {
|
||
ok(0, "$file cannot be located --ERROR");
|
||
print $fh "Looked in:\n " . join("\n ", @path) . "\n";
|
||
}
|
||
}
|
||
}
|
||
|
||
foreach my $include_path (@include_paths) {
|
||
# Processes all the templates to make sure they have good syntax
|
||
my $provider = Template::Provider->new(
|
||
{
|
||
INCLUDE_PATH => $include_path ,
|
||
# Need to define filters used in the codebase, they don't
|
||
# actually have to function in this test, just be defined.
|
||
# See Template.pm for the actual codebase definitions.
|
||
|
||
# Initialize templates (f.e. by loading plugins like Hook).
|
||
PRE_PROCESS => "global/initialize.none.tmpl",
|
||
|
||
FILTERS =>
|
||
{
|
||
html_linebreak => sub { return $_; },
|
||
no_break => sub { return $_; } ,
|
||
js => sub { return $_ } ,
|
||
base64 => sub { return $_ } ,
|
||
inactive => [ sub { return sub { return $_; } }, 1] ,
|
||
closed => [ sub { return sub { return $_; } }, 1] ,
|
||
obsolete => [ sub { return sub { return $_; } }, 1] ,
|
||
url_quote => sub { return $_ } ,
|
||
css_class_quote => sub { return $_ } ,
|
||
xml => sub { return $_ } ,
|
||
quoteUrls => sub { return $_ } ,
|
||
bug_link => [ sub { return sub { return $_; } }, 1] ,
|
||
csv => sub { return $_ } ,
|
||
unitconvert => sub { return $_ },
|
||
time => sub { return $_ } ,
|
||
wrap_comment => sub { return $_ },
|
||
none => sub { return $_ } ,
|
||
ics => [ sub { return sub { return $_; } }, 1] ,
|
||
},
|
||
}
|
||
);
|
||
|
||
foreach my $file (@{$actual_files{$include_path}}) {
|
||
my $path = File::Spec->catfile($include_path, $file);
|
||
if (-e $path) {
|
||
my ($data, $err) = $provider->fetch($file);
|
||
|
||
if (!$err) {
|
||
ok(1, "$file syntax ok");
|
||
}
|
||
else {
|
||
ok(0, "$file has bad syntax --ERROR");
|
||
print $fh $data . "\n";
|
||
}
|
||
}
|
||
else {
|
||
ok(1, "$path doesn't exist, skipping test");
|
||
}
|
||
}
|
||
|
||
# check to see that all templates have a version string:
|
||
# disabled for lx-office
|
||
|
||
# foreach my $file (@{$actual_files{$include_path}}) {
|
||
# my $path = File::Spec->catfile($include_path, $file);
|
||
# open(TMPL, $path);
|
||
# my $firstline = <TMPL>;
|
||
# if ($firstline =~ /\d+\.\d+\@[\w\.-]+/) {
|
||
# ok(1,"$file has a version string");
|
||
# } else {
|
||
# ok(0,"$file does not have a version string --ERROR");
|
||
# }
|
||
# close(TMPL);
|
||
# }
|
||
}
|
||
|
||
exit 0;
|
t/005no_tabs.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Jacob Steenhagen.
|
||
# Portions created by Jacob Steenhagen are
|
||
# Copyright (C) 2001 Jacob Steenhagen. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
|
||
# David D. Kilzer <ddkilzer@kilzer.net>
|
||
#
|
||
|
||
#################
|
||
#Bugzilla Test 5#
|
||
#####no_tabs#####
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
|
||
use Support::Files;
|
||
use Support::Templates;
|
||
|
||
use File::Spec;
|
||
use Test::More tests => ( scalar(@Support::Files::testitems)
|
||
+ $Support::Templates::num_actual_files);
|
||
|
||
my @testitems = @Support::Files::testitems;
|
||
for my $path (@Support::Templates::include_paths) {
|
||
push(@testitems, map(File::Spec->catfile($path, $_),
|
||
Support::Templates::find_actual_files($path)));
|
||
}
|
||
|
||
foreach my $file (@testitems) {
|
||
open (FILE, "$file");
|
||
if (grep /\t/, <FILE>) {
|
||
ok(0, "$file contains tabs --WARNING");
|
||
} else {
|
||
ok(1, "$file has no tabs");
|
||
}
|
||
close (FILE);
|
||
}
|
||
|
||
exit 0;
|
t/006spellcheck.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla Tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Zach Lipton
|
||
# Portions created by Zach Lipton are
|
||
# Copyright (C) 2002 Zach Lipton. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Zach Lipton <zach@zachlipton.com>
|
||
|
||
|
||
#################
|
||
#Bugzilla Test 6#
|
||
####Spelling#####
|
||
|
||
use lib 't';
|
||
use Support::Files;
|
||
|
||
BEGIN { # yes the indenting is off, deal with it
|
||
#add the words to check here:
|
||
@evilwords = qw(
|
||
anyways
|
||
arbitary
|
||
databasa
|
||
dependan
|
||
existance
|
||
existant
|
||
paramater
|
||
varsion
|
||
fomr
|
||
);
|
||
|
||
$testcount = scalar(@Support::Files::testitems);
|
||
}
|
||
|
||
use Test::More tests => $testcount;
|
||
|
||
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
|
||
# This will handle verbosity for us automatically.
|
||
my $fh;
|
||
{
|
||
local $^W = 0; # Don't complain about non-existent filehandles
|
||
if (-e \*Test::More::TESTOUT) {
|
||
$fh = \*Test::More::TESTOUT;
|
||
} elsif (-e \*Test::Builder::TESTOUT) {
|
||
$fh = \*Test::Builder::TESTOUT;
|
||
} else {
|
||
$fh = \*STDOUT;
|
||
}
|
||
}
|
||
|
||
my @testitems = @Support::Files::testitems;
|
||
|
||
# at last, here we actually run the test...
|
||
my $evilwordsregexp = join('|', @evilwords);
|
||
|
||
foreach my $file (@testitems) {
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
|
||
if (open (FILE, $file)) { # open the file for reading
|
||
|
||
my $found_word = '';
|
||
|
||
while (my $file_line = <FILE>) { # and go through the file line by line
|
||
if ($file_line =~ /($evilwordsregexp)/i) { # found an evil word
|
||
$found_word = $1;
|
||
last;
|
||
}
|
||
}
|
||
|
||
close (FILE);
|
||
|
||
if ($found_word) {
|
||
ok(0,"$file: found SPELLING ERROR $found_word --WARNING");
|
||
} else {
|
||
ok(1,"$file does not contain registered spelling errors");
|
||
}
|
||
} else {
|
||
ok(0,"could not open $file for spellcheck --WARNING");
|
||
}
|
||
}
|
||
|
||
exit 0;
|
t/011pod.t | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla Tests.
|
||
#
|
||
# Contributor(s): Frédéric Buclin <LpSolit@gmail.com>
|
||
|
||
|
||
##################
|
||
#Bugzilla Test 11#
|
||
##POD validation##
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
|
||
use Support::Files;
|
||
use Pod::Checker;
|
||
|
||
use Test::More tests => scalar(@Support::Files::testitems);
|
||
|
||
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
|
||
# This will handle verbosity for us automatically.
|
||
my $fh;
|
||
{
|
||
local $^W = 0; # Don't complain about non-existent filehandles
|
||
if (-e \*Test::More::TESTOUT) {
|
||
$fh = \*Test::More::TESTOUT;
|
||
} elsif (-e \*Test::Builder::TESTOUT) {
|
||
$fh = \*Test::Builder::TESTOUT;
|
||
} else {
|
||
$fh = \*STDOUT;
|
||
}
|
||
}
|
||
|
||
my @testitems = @Support::Files::testitems;
|
||
|
||
foreach my $file (@testitems) {
|
||
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
|
||
next if (!$file); # skip null entries
|
||
my $error_count = podchecker($file, $fh);
|
||
if ($error_count < 0) {
|
||
ok(1,"$file does not contain any POD");
|
||
} elsif ($error_count == 0) {
|
||
ok(1,"$file has correct POD syntax");
|
||
} else {
|
||
ok(0,"$file has incorrect POD syntax --ERROR");
|
||
}
|
||
}
|
||
|
||
exit 0;
|
t/README | ||
---|---|---|
Directory for automated test scripts.
|
t/README.de | ||
---|---|---|
Lx-Office Testumgebung
|
||
|
||
Mit der hier beschriebenen Testumgebung ist es m?glich, Lx Office
|
||
automatisiert zu testen. Automatische Tests haben den gro?en
|
||
Vorteil, das verschiedene Standardtests nicht immer wieder von
|
||
Hand durchgespielt werden m?ssen, sondern einmal in einem Skript
|
||
verschriftet immer wieder verwendet werden k?nnen.
|
||
Weitere Informationen k?nnen im Wiki nachgelesen und erg?nzt werden:
|
||
http://wiki.lx-system.de/index.php/Automatisiertes_Testen_von_Modulen
|
||
|
||
|
||
|
||
Aufbau der Testumgebung
|
||
Im Verzeichnis t/ finden sich alle testrelevanten Skripte.Der
|
||
Aufruf der Tests folgt ?ber
|
||
#perl t/lx-office.t
|
||
|
||
lx-office.t ruft alle Einzeltests der Reihe nach auf und fasst sie
|
||
?bersichtlich zusammen. Die Einzeltests befinden sich in einem
|
||
Unterordner von t/. Jeder Unterorder enth?lt eine Datei AllTests.t,
|
||
die wiederrum alle einzelnen Tests des Unterordners aufruft.
|
||
|
||
|
||
|
||
t/lxtest.conf t/lxtest.conf.default
|
||
F?r die einzelnen Tests werden verschiedene Packetvariablen (globals)
|
||
zur Verf?gung gestellt, um die Testskripte einfach auf
|
||
unterschiedliche Installationen anpassen zu k?nnen und um sich auf
|
||
die selbe Test-Datenbank und denselben Test-Benutzer beziehen zu k?nnen.
|
||
|
||
Die Datei t/lxtest.conf.default muss zun?chst nach t/lxtest.conf
|
||
kopiert werden. Dann ist die Datei t/lxtest.conf auf die lokalen
|
||
Gegebenheiten anzupassen. Besnders die f?r Selenium n?tigen
|
||
Einstellungen bed?rfen einer ?berarbeitung.
|
||
|
||
Definiert werden die Variablen in der Datei t/lxtest.conf.
|
||
Aufgerufen werden die Variablen $lxtest->{VARIABLE}.
|
||
Es ist ratsam, die vorhandenen Tests zu untersuchen, um sich ein Bild
|
||
von den M?glichkeiten zu machen.
|
||
|
||
|
||
|
||
Selenium
|
||
Selenium ist eine Testsuite, mit der man Browserinteraktionen
|
||
simulieren und die Ergebnisse auswerten kann. Der unschlagbare
|
||
Vorteil von Selenium f?r das Testen von Lx ist es, dass es
|
||
m?glich wird, eine Test-Datenbank in einfachen Schritten
|
||
erstellen zu k?nnen. Um Seleniumtests durchf?hren zu k?nnen,
|
||
ist es n?tig, das Packet Selenium Remote Control (Selenium RC)
|
||
lokal zu installieren (Java Runtime ebenfalls erforderlich).
|
||
Selenium RC gibt es unter:
|
||
http://www.openqa.org/selenium-rc/
|
||
|
||
F?r den Betrieb von Selenium ist eine lokale Workstation mit
|
||
Browserumgebung n?tig.
|
||
|
||
Der Aufruf von selenium erfolgt unter Windows bspw. so:
|
||
C:\java -jar "C:\selenium-remote-control-0.9.0
|
||
\server\selenium-server.jar"
|
||
|
||
Unter Linux bspw. so:
|
||
<FIXME>
|
||
|
||
Die lokalen Einstellungen sind unbedingt in der
|
||
t/lxtest.conf nachzutragen! Weitere Infos unter
|
||
http://www.openqa.org/selenium-rc/
|
||
|
||
Dann reicht ein Start von
|
||
#perl t/lx-office.t
|
||
um dem Testskript bei der Arbeit zuzuschauen.
|
||
|
||
Leider ist es n?tig, auf dem Seleniumserver nach jedem Aufruf
|
||
des Testskripts das Sicherheitszertifikat von LINET Services zu
|
||
akzeptieren, was etwas nervig ist.
|
||
|
||
|
||
t/selenium/
|
||
Der Ordner selenium beinhaltet alle einzelnen selenium Testskripte.
|
||
Aufgerufen werden die Skripte ?ber t/selenium/AllTests.t .
|
||
Neue Tests m?ssen in dieser Datei angemeldet werden.
|
||
Ziel ist es eine Demodatenbank von Lx mit Daten zu f?llen und die
|
||
Abh?ngigkeiten untereinander zu pr?fen. Dazu sind die
|
||
individuellen Testskripte nummeriert (001NAME.t bis 999NAME.t) um
|
||
sie der Reihe nach abzuarbeiten.
|
||
|
||
Die folgenden Skripte sind bereits installiert:
|
||
|
||
001CreateTestDatabase.t Erzeugt eine neue Testdatenbank
|
||
002CreateTestUser.t Erzeugt einen neuen Testbenutzer
|
||
...
|
||
...
|
||
998DeleteTestUser.t L?scht den Testbenutzer
|
||
999DeleteTestDatabase.t L?scht die Testdatenbank
|
||
|
||
Dazwischen befinden sich die Skripte, um eine Demodatenbank
|
||
aufzubauen und zu pr?fen.
|
||
|
||
|
||
|
||
t/backend/
|
||
In diesem Ordner befinden sich Backend Testskripte.
|
||
|
||
|
||
|
||
t/frontend/
|
||
In diesem Ordner befinden sich Frontend Testskripte, die nicht
|
||
unter selenium getestet werden.
|
||
|
||
|
||
|
||
Was wenn ein Test fehlschl?gt?
|
||
Das Fehlschlagen von Tests kann verschiedene Gr?nde haben.
|
||
1. Der Test selbst ist fehlerhaft.
|
||
2. Es haben sich Lx Screens ver?ndert, so das der Test von
|
||
falschen Voraussetzungen ausgeht
|
||
3. Die zu testende Funktion ist fehlerhaft
|
||
|
||
Nachdem 1. und 2. ausgeschlossen wurden, sollte zu 3. ein Bugreport
|
||
angelegt werden.
|
||
Bugreports unter https://lx-office.linet-services.de/bugzilla/
|
||
anlegen.
|
||
|
||
|
||
|
||
Eigene Tests
|
||
Eigene testskripte k?nnen einfach in die Testumgebung eingebunden
|
||
werden. Die vorhandenen Skripte k?nnen als Anleitung dienen.
|
||
Bei Selenium Tests ist es am leichtesten, mit Firefox und der
|
||
Selenium IDE Extension Testpfade einfach aufzuzeichnen.
|
||
( http://www.openqa.org/selenium-ide/ )
|
||
Dann werden die Selenium IDE Testaufzeichnungen in Perl
|
||
umgewandelt und angepasst. Fertige Skripte werden mit einer
|
||
laufenden Nummer versehen und in den Ordner t/selenium/ kopiert.
|
||
Dann wird das Skript in der Datei t/selenium/AllTests.t eingef?gt.
|
||
Ein erster Probelauf mit
|
||
#perl t/selenium/AllTests.t sollte den Test absolvieren.
|
||
(Dabei kann es n?tig sein, andere Tests auszukommentieren, weil
|
||
selenium Tests mitunter lange Laufzeiten haben k?nnen, oder weil die Demodatenbank
|
||
und der Benutzer am Ende zu Debugging Zwecken nicht gel?scht werden
|
||
sollen.)
|
||
|
||
|
t/Support/Files.pm | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla Tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Zach Lipton
|
||
# Portions created by Zach Lipton are
|
||
# Copyright (C) 2001 Zach Lipton. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Zach Lipton <zach@zachlipton.com>
|
||
# Joel Peshkin <bugreport@peshkin.net>
|
||
|
||
|
||
package Support::Files;
|
||
|
||
use File::Find;
|
||
|
||
# exclude_deps is a hash of arrays listing the files to be excluded
|
||
# if a module is not available
|
||
#
|
||
@additional_files = ();
|
||
%exclude_deps = (
|
||
'XML::Twig' => ['importxml.pl'],
|
||
'Net::LDAP' => ['Bugzilla/Auth/Verify/LDAP.pm'],
|
||
'Email::Reply' => ['email_in.pl'],
|
||
'Email::MIME::Attachment::Stripper' => ['email_in.pl']
|
||
);
|
||
|
||
|
||
@files = glob('*');
|
||
find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, 'SL');
|
||
|
||
sub have_pkg {
|
||
my ($pkg) = @_;
|
||
my ($msg, $vnum, $vstr);
|
||
no strict 'refs';
|
||
eval { my $p; ($p = $pkg . ".pm") =~ s!::!/!g; require $p; };
|
||
return !($@);
|
||
}
|
||
|
||
@exclude_files = ();
|
||
foreach $dep (keys(%exclude_deps)) {
|
||
if (!have_pkg($dep)) {
|
||
push @exclude_files, @{$exclude_deps{$dep}};
|
||
}
|
||
}
|
||
|
||
sub isTestingFile {
|
||
my ($file) = @_;
|
||
my $exclude;
|
||
foreach $exclude (@exclude_files) {
|
||
if ($file eq $exclude) { return undef; } # get rid of excluded files.
|
||
}
|
||
|
||
if ($file =~ /\.cgi$|\.pl$|\.pm$/) {
|
||
return 1;
|
||
}
|
||
my $additional;
|
||
foreach $additional (@additional_files) {
|
||
if ($file eq $additional) { return 1; }
|
||
}
|
||
return undef;
|
||
}
|
||
|
||
foreach $currentfile (@files) {
|
||
if (isTestingFile($currentfile)) {
|
||
push(@testitems,$currentfile);
|
||
}
|
||
}
|
||
|
||
|
||
1;
|
t/Support/Systemexec.pm | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
|
||
package Support::Systemexec;
|
||
require Exporter;
|
||
@ISA = qw(Exporter);
|
||
@EXPORT = qw(system exec);
|
||
@EXPORT_OK = qw();
|
||
sub system($$@) {
|
||
1;
|
||
}
|
||
sub exec($$@) {
|
||
1;
|
||
}
|
||
1;
|
t/Support/Templates.pm | ||
---|---|---|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||
#
|
||
# The contents of this file are subject to the Mozilla Public
|
||
# License Version 1.1 (the "License"); you may not use this file
|
||
# except in compliance with the License. You may obtain a copy of
|
||
# the License at http://www.mozilla.org/MPL/
|
||
#
|
||
# Software distributed under the License is distributed on an "AS
|
||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||
# implied. See the License for the specific language governing
|
||
# rights and limitations under the License.
|
||
#
|
||
# The Original Code are the Bugzilla tests.
|
||
#
|
||
# The Initial Developer of the Original Code is Jacob Steenhagen.
|
||
# Portions created by Jacob Steenhagen are
|
||
# Copyright (C) 2001 Jacob Steenhagen. All
|
||
# Rights Reserved.
|
||
#
|
||
# Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
|
||
# David D. Kilzer <ddkilzer@kilzer.net>
|
||
# Tobias Burnus <burnus@net-b.de>
|
||
#
|
||
|
||
package Support::Templates;
|
||
|
||
use strict;
|
||
|
||
use lib 't';
|
||
use base qw(Exporter);
|
||
@Support::Templates::EXPORT =
|
||
qw(@languages @include_paths %include_path @referenced_files
|
||
%actual_files $num_actual_files);
|
||
use vars qw(@languages @include_paths %include_path @referenced_files
|
||
%actual_files $num_actual_files);
|
||
|
||
use Support::Files;
|
||
|
||
use File::Find;
|
||
use File::Spec;
|
||
|
||
# The available template languages
|
||
@languages = ();
|
||
|
||
# The colon separated includepath per language
|
||
%include_path = ();
|
||
|
||
# All include paths
|
||
@include_paths = ();
|
||
|
||
# Files which are referenced in the cgi files
|
||
@referenced_files = ();
|
||
|
||
# All files sorted by include_path
|
||
%actual_files = ();
|
||
|
||
# total number of actual_files
|
||
$num_actual_files = 0;
|
||
|
||
# Scan for the template available languages and include paths
|
||
#{
|
||
# opendir(DIR, "templates/webpages") || die "Can't open 'templates': $!";
|
||
# my @files = grep { /^[a-z-]+$/i } readdir(DIR);
|
||
# closedir DIR;
|
||
#
|
||
# foreach my $langdir (@files) {
|
||
# next if($langdir =~ /^CVS$/i);
|
||
#
|
||
# my $path = File::Spec->catdir('templates', $langdir, 'custom');
|
||
# my @dirs = ();
|
||
# push(@dirs, $path) if(-d $path);
|
||
# $path = File::Spec->catdir('templates', $langdir, 'extension');
|
||
# push(@dirs, $path) if(-d $path);
|
||
# $path = File::Spec->catdir('templates', $langdir, 'default');
|
||
# push(@dirs, $path) if(-d $path);
|
||
#
|
||
# next if(scalar(@dirs) == 0);
|
||
# push(@languages, $langdir);
|
||
# push(@include_paths, @dirs);
|
||
# $include_path{$langdir} = join(":",@dirs);
|
||
# }
|
||
#}
|
||
|
||
my @files;
|
||
|
||
# Local subroutine used with File::Find
|
||
sub find_templates {
|
||
# Prune CVS directories
|
||
if (-d $_ && $_ eq 'CVS') {
|
||
$File::Find::prune = 1;
|
||
return;
|
||
}
|
||
|
||
# Only include files ending in '.html'
|
||
if (-f $_ && $_ =~ m/\.html$/i) {
|
||
my $filename;
|
||
my $local_dir = File::Spec->abs2rel($File::Find::dir,
|
||
$File::Find::topdir);
|
||
|
||
# File::Spec 3.13 and newer return "." instead of "" if both
|
||
# arguments of abs2rel() are identical.
|
||
$local_dir = "" if ($local_dir eq ".");
|
||
|
||
if ($local_dir) {
|
||
$filename = File::Spec->catfile($local_dir, $_);
|
||
} else {
|
||
$filename = $_;
|
||
}
|
||
|
||
push(@files, $filename);
|
||
}
|
||
}
|
||
|
||
# Scan the given template include path for templates
|
||
sub find_actual_files {
|
||
my $include_path = $_[0];
|
||
@files = ();
|
||
find(\&find_templates, $include_path);
|
||
return @files;
|
||
}
|
||
|
||
@include_paths = qw(templates/webpages);
|
||
|
||
foreach my $include_path (@include_paths) {
|
||
$actual_files{$include_path} = [ find_actual_files($include_path) ];
|
||
$num_actual_files += scalar(@{$actual_files{$include_path}});
|
||
}
|
||
|
||
# Scan Bugzilla's perl code looking for templates used and put them
|
||
# in the @referenced_files array to be used by the 004template.t test.
|
||
my %seen;
|
||
|
||
foreach my $file (@Support::Files::testitems) {
|
||
open (FILE, $file);
|
||
my @lines = <FILE>;
|
||
close (FILE);
|
||
foreach my $line (@lines) {
|
||
# if ($line =~ m/template->process\(\"(.+?)\", .+?\)/) {
|
||
if ($line =~ m/->parse_html_template\((['"])(.+?)\1/) {
|
||
my $template = $2;
|
||
# Ignore templates with $ in the name, since they're
|
||
# probably vars, not real files
|
||
next if $template =~ m/\$/;
|
||
next if $seen{$template};
|
||
push (@referenced_files, $template);
|
||
$seen{$template} = 1;
|
||
}
|
||
}
|
||
}
|
||
|
||
1;
|
t/backend/README.backend | ||
---|---|---|
This folder contais the backend testscrips for Lx.
|
||
The Lx backend is the module libery under SL.
|
||
Backend tests don't need selenium, and are only able
|
||
to test local installations.
|
t/demolx/AllTests.t | ||
---|---|---|
#=====================================================================
|
||
# LX-Office ERP
|
||
# Copyright (C) 2006
|
||
# Web http://www.lx-office.org
|
||
#
|
||
#=====================================================================
|
||
#
|
||
# Author: Udo Spallek
|
||
# Email: udono@gmx.net
|
||
#
|
||
# This program is free software; you can redistribute it and/or modify
|
||
# it under the terms of the GNU General Public License as published by
|
||
# the Free Software Foundation; either version 2 of the License, or
|
||
# (at your option) any later version.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU General Public License for more details.
|
||
# You should have received a copy of the GNU General Public License
|
||
# along with this program; if not, write to the Free Software
|
||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
#======================================================================
|
||
#
|
||
# Selenium Main Caller
|
||
# Call all Selenium scripts from here. To use Selenium tests in
|
||
# Lx-Office you need to Install Selenium Remote Control. Take a look at
|
||
# the README Document for further informatinons on installing Selenium
|
||
# and testing Lx-Office and of course writing your own testcases.
|
||
#
|
||
#######################################################################
|
||
no strict;
|
||
push @INC, ['/t/selenium'];
|
||
use vars qw( $lxdebug $lxtest $sel );
|
||
use strict;
|
||
use Carp;
|
||
|
||
use Test::WWW::Selenium;
|
||
use Test::More;
|
||
use IO::Socket;
|
||
|
||
eval { require('t/lxtest.conf'); };
|
||
if ($@) {
|
||
diag("No test configuration found in t/lxtest.conf.\n
|
||
Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n");
|
||
exit 0;
|
||
};
|
||
|
||
sub server_is_running {
|
||
return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost},
|
||
PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport},
|
||
);
|
||
}
|
||
if (server_is_running) {
|
||
plan tests => 204; # Need to be cutomized
|
||
}
|
||
else {
|
||
plan skip_all => "No selenium server found! "
|
||
."Maybe you forgot to start it or "
|
||
."the preferences in t/lxtest.conf doesen't fit to your system";
|
||
# exit 0;
|
||
}
|
||
|
||
diag('Pretests and initialisation');
|
||
|
||
|
||
|
||
$lxtest->{test_id} = time; # create individual ids by unixtime
|
||
$lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id};
|
||
$lxtest->{testuserpasswd} = $lxtest->{test_id};
|
||
$lxtest->{db} = $lxtest->{db} . $lxtest->{test_id};
|
||
|
||
ok(defined $lxtest->{rpw}, "Get root password");
|
||
|
||
ok(defined $lxtest->{dbhost}, "found dbhost in config");
|
||
ok(defined $lxtest->{dbport}, "found dbport in config");
|
||
ok(defined $lxtest->{dbuser}, "found dbuser in config");
|
||
ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config");
|
||
|
||
$lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
|
||
|
||
|
||
|
||
|
||
|
||
eval { $sel = Test::WWW::Selenium->new(
|
||
host => $lxtest->{seleniumhost},
|
||
port => $lxtest->{seleniumport},
|
||
browser => $lxtest->{seleniumbrowser},
|
||
browser_url => $lxtest->{lxadmin},
|
||
auto_stop => '0',
|
||
);
|
||
};
|
||
if ($@) {
|
||
diag("No Selenium Server running, or wrong preferences\n\n");
|
||
exit 0;
|
||
}
|
||
|
||
ok(defined $sel, 'Creating Selenium Object');
|
||
|
||
diag('Starting Selenium tests...');
|
||
|
||
opendir(SCRIPTS, 't/selenium/testscripts');
|
||
my @testscripts = sort readdir(SCRIPTS);
|
||
|
||
foreach my $script (@testscripts){
|
||
my $file = "t/selenium/testscripts/" . $script;
|
||
require_ok($file) if ( $script =~ /^\d\d\d.*\.t$/ );
|
||
}
|
||
exit 1;
|
||
|
||
$sel=''; # Destroy selenium object
|
||
|
||
exit 1;
|
||
|
t/demolx/README | ||
---|---|---|
This directory contains all selenium testscripts for lx-office.
|
||
Selenium testscrips are the prefered way to test the higher lx
|
||
functionalities. For the selenium tests you need to install and
|
||
run a local selenium server on a machine whitch is able to start
|
||
a browser session. See README for more informations.
|
||
|
||
|
t/demolx/cleanup.pl | ||
---|---|---|
#=====================================================================
|
||
# LX-Office ERP
|
||
# Copyright (C) 2006
|
||
# Web http://www.lx-office.org
|
||
#
|
||
#=====================================================================
|
||
#
|
||
# Author: Udo Spallek
|
||
# Email: udono@gmx.net
|
||
#
|
||
# This program is free software; you can redistribute it and/or modify
|
||
# it under the terms of the GNU General Public License as published by
|
||
# the Free Software Foundation; either version 2 of the License, or
|
||
# (at your option) any later version.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU General Public License for more details.
|
||
# You should have received a copy of the GNU General Public License
|
||
# along with this program; if not, write to the Free Software
|
||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||
#======================================================================
|
||
#
|
||
# Selenium Cleanup Script
|
||
# To clean up all the messy databases and users while debugging testcases
|
||
#
|
||
#######################################################################
|
||
no strict;
|
||
push @INC, ['/t/selenium'];
|
||
use vars qw( $lxdebug $lxtest $sel );
|
||
use strict;
|
||
use Carp;
|
||
|
||
use WWW::Selenium;
|
||
use IO::Socket;
|
||
|
||
my $cleanedupdb = '';
|
||
my $cleanedupusers = '';
|
||
|
||
eval { require('t/lxtest.conf'); };
|
||
if ($@) {
|
||
print "No test configuration found in t/lxtest.conf.\n
|
||
Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n";
|
||
exit 0;
|
||
};
|
||
|
||
sub server_is_running {
|
||
return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost},
|
||
PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport},
|
||
);
|
||
}
|
||
if (server_is_running) {
|
||
}
|
||
else {
|
||
exit 0;
|
||
}
|
||
|
||
$lxtest->{testuserlogin} = $lxtest->{testlogin};
|
||
$lxtest->{db} = $lxtest->{db};
|
||
|
||
$lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter";
|
||
|
||
eval { $sel = WWW::Selenium->new(
|
||
host => $lxtest->{seleniumhost},
|
||
port => $lxtest->{seleniumport},
|
||
browser => $lxtest->{seleniumbrowser},
|
||
browser_url => $lxtest->{lxadmin},
|
||
auto_stop => '0',
|
||
);
|
||
};
|
||
if ($@) {
|
||
print "No Selenium Server running, or wrong preferences\n\n";
|
||
exit 0;
|
||
}
|
||
|
||
|
||
print "\nStarting Testdebugging Cleanup...\n";
|
||
|
||
|
||
### Delete user
|
||
|
||
$sel->start;
|
||
print "Cleanup all users '$lxtest->{testuserlogin}*'\n";
|
||
$sel->open($lxtest->{lxadmin});
|
||
|
||
my @links= $sel->get_all_links();
|
||
my $testuserlogin = $lxtest->{testuserlogin};
|
||
|
||
foreach my $link (@links) {
|
||
|
||
if ($link =~ /$testuserlogin\d\d\d\d\d\d\d\d\d\d/){
|
||
$sel->click("link=$lxtest->{testuserlogin}11*");
|
||
$sel->wait_for_page_to_load($lxtest->{timeout});
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"L?schen\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeout});
|
||
$cleanedupusers .= " $link\n";
|
||
}
|
||
}
|
||
|
||
print "Lock the system\n";
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeout});
|
||
|
||
print "Cleanup all test databasees: '$lxtest->{db}*'\n";
|
||
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeout});
|
||
$sel->type("dbhost", $lxtest->{dbhost});
|
||
$sel->type("dbport", $lxtest->{dbport});
|
||
$sel->type("dbuser", $lxtest->{dbuser});
|
||
$sel->type("dbpasswd", $lxtest->{dbpasswd});
|
||
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeoutlong});
|
||
|
||
my $field = $sel->get_body_text();
|
||
my $database= $lxtest->{db};
|
||
my @fields = split(' ', $field);
|
||
|
||
|
||
foreach my $field (@fields) {
|
||
|
||
if ($field =~ /$database\d\d\d\d\d\d\d\d\d\d/){
|
||
$sel->open($lxtest->{lxadmin});
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeout});
|
||
$sel->type("dbhost", $lxtest->{dbhost});
|
||
$sel->type("dbport", $lxtest->{dbport});
|
||
$sel->type("dbuser", $lxtest->{dbuser});
|
||
$sel->type("dbpasswd", $lxtest->{dbpasswd});
|
||
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeoutlong});
|
||
$sel->check("name=db value=$field");
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
|
||
$cleanedupdb .= " $field\n";
|
||
|
||
}
|
||
}
|
||
|
||
$sel->open($lxtest->{lxadmin});
|
||
print "Unlock the system\n";
|
||
|
||
$sel->click("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
|
||
$sel->wait_for_page_to_load($lxtest->{timeout});
|
||
|
||
$cleanedupdb = "none.\n" if ($cleanedupdb eq '');
|
||
$cleanedupusers = "none.\n" if ($cleanedupusers eq '');
|
||
|
||
print "Ready. \nReport:\n--- Cleaned up Users:\n$cleanedupusers---Cleaned up Databases:\n$cleanedupdb";
|
||
|
||
$sel->stop;
|
||
|
||
exit 1;
|
||
|
||
|
t/demolx/testscripts/001CreateTestDatabase.t | ||
---|---|---|
### Create Database
|
||
|
||
$sel->open_ok($lxtest->{lxadmin});
|
||
$sel->title_is("Lx-Office ERP Administration -");
|
||
|
||
diag('Lock the system');
|
||
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System sperren\")]");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
|
||
|
||
diag("Create test database '$lxtest->{db}'");
|
||
$sel->title_is("Lx-Office ERP Administration -");
|
||
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
|
||
$sel->title_is("Lx-Office ERP / Datenbankadministration -");
|
||
$sel->type_ok("dbuser", $lxtest->{dbuser});
|
||
$sel->type_ok("dbpasswd", $lxtest->{dbpasswd});
|
||
$sel->type_ok("dbuser", $lxtest->{dbuser});
|
||
$sel->type_ok("dbhost", $lxtest->{dbhost});
|
||
$sel->type_ok("dbport", $lxtest->{dbport});
|
||
$sel->type_ok("dbdefault", $lxtest->{dbdefault});
|
||
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank anlegen\")]");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
|
||
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -");
|
||
$sel->type_ok("db", $lxtest->{db});
|
||
$sel->select_ok("encoding", "label=ISO 8859-1");
|
||
$sel->click_ok("//input[(\@name=\"chart\") and (\@value=\"Germany-DATEV-SKR03EU\")]");
|
||
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong});
|
||
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -");
|
||
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
|
||
$sel->title_is("Lx-Office ERP Administration -");
|
||
|
||
diag('Unlock the system');
|
||
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
|
||
$sel->title_is("Lx-Office ERP Administration -");
|
t/demolx/testscripts/002CreateTestUser.t | ||
---|---|---|
|
||
### Create new user
|
||
diag("Create test user '$lxtest->{testuserlogin}'");
|
||
$sel->open_ok($lxtest->{lxadmin});
|
||
$sel->title_is("Lx-Office ERP Administration -");
|
||
$sel->click_ok("action");
|
||
$sel->wait_for_page_to_load_ok($lxtest->{timeout});
|
||
$sel->title_is("Lx-Office ERP Administration / Benutzer erfassen -");
|
||
$sel->type_ok("login", $lxtest->{testuserlogin});
|
||
$sel->type_ok("password", $lxtest->{testuserpasswd});
|
||
$sel->type_ok("name", "Selenium");
|
Auch abrufbar als: Unified diff
Automatisierte Syntaxtests, Framework für spätere Modultests.
Selenium Tests nach old verschoben, deprecated.