Add a new method to t/lib/WebGUI/Test.pm to return the path to the test

collateral.
Update all tests to use the new method.
Change testCodebase.pl to run long tests by default.  To disable the
long tests, use the --noLongTests switch.
This commit is contained in:
Colin Kuskie 2006-12-15 23:17:22 +00:00
parent 40e3967b19
commit 9d0894b674
6 changed files with 55 additions and 29 deletions

View file

@ -10,6 +10,7 @@
use FindBin;
use strict;
use File::Spec;
use lib "$FindBin::Bin/../../lib";
##The goal of this test is to test the creation of Article Wobjects.
@ -64,13 +65,12 @@ foreach my $newSetting (keys %{$newArticleSettings}) {
}
# Test the duplicate method... not for assets, just the extended duplicate functionality of the article wobject
my $path = $session->config->getWebguiRoot()."/t/supporting_collateral/";
my $filename = "page_title.jpg";
my $pathedFile = File::Spec->catfile(WebGUI::Test->getTestCollateralPath, $filename);
# Use some test collateral to create a storage location and assign it to our article
my $storage = WebGUI::Storage::Image->create($session);
system("pwd");
my $storedFilename = $storage->addFileFromFilesystem($path.$filename);
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
my $filenameOK = is ($storedFilename, $filename, 'storage created correctly');
diag(join("\n", @{ $storage->getErrors })) unless $filenameOK;

View file

@ -14,7 +14,8 @@ use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More; # increment this value for each test you create
use File::Copy qw(cp);
use File::Copy;
use File::Spec;
my $session = WebGUI::Test->session;
@ -71,15 +72,19 @@ SKIP: {
}
sub installPigLatin {
my $wgLib = WebGUI::Test->lib;
mkdir join('/', $wgLib, 'WebGUI/i18n/PigLatin');
cp 'supporting_collateral/WebGUI.pm', join('/', $wgLib, 'WebGUI/i18n/PigLatin/WebGUI.pm');
cp 'supporting_collateral/PigLatin.pm', join('/', $wgLib, 'WebGUI/i18n/PigLatin.pm');
mkdir File::Spec->catdir(WebGUI::Test->lib, 'WebGUI', 'i18n', 'PigLatin');
copy(
File::Spec->catfile(WebGUI::Test->getTestCollateralPath, 'WebGUI.pm'),
File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/)
);
copy(
File::Spec->catfile(WebGUI::Test->getTestCollateralPath, 'PigLatin.pm'),
File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/)
);
}
END: {
my $wgLib = WebGUI::Test->lib;
unlink join('/', $wgLib, 'WebGUI/i18n/PigLatin/WebGUI.pm');
unlink join('/', $wgLib, 'WebGUI/i18n/PigLatin.pm');
rmdir join('/', $wgLib, 'WebGUI/i18n/PigLatin');
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/);
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/);
rmdir File::Spec->catdir(WebGUI::Test->lib, qw/WebGUI i18n PigLatin/);
}

View file

@ -3,7 +3,7 @@ package WebGUI::Test;
use strict;
use warnings;
our ( $SESSION, $WEBGUI_ROOT, $CONFIG_FILE, $WEBGUI_LIB );
our ( $SESSION, $WEBGUI_ROOT, $CONFIG_FILE, $WEBGUI_LIB, $WEBGUI_TEST_COLLATERAL );
use Config qw[];
use IO::Handle qw[];
@ -50,6 +50,7 @@ BEGIN {
$CONFIG_FILE = ( File::Spec->splitpath( $WEBGUI_ROOT ) )[2];
$WEBGUI_ROOT = substr( $WEBGUI_ROOT, 0, index( $WEBGUI_ROOT, File::Spec->catdir( 'etc', $CONFIG_FILE ) ) );
$WEBGUI_ROOT = File::Spec->canonpath($WEBGUI_ROOT);
$WEBGUI_TEST_COLLATERAL = File::Spec->catdir($WEBGUI_ROOT, 't', 'supporting_collateral');
$WEBGUI_LIB ||= File::Spec->catpath( (File::Spec->splitpath($WEBGUI_ROOT))[0], $WEBGUI_ROOT, 'lib' );
@ -107,4 +108,8 @@ sub root {
return $WEBGUI_ROOT;
}
sub getTestCollateralPath {
return $WEBGUI_TEST_COLLATERAL;
}
1;