fix - export fails with strange urls. Factored url to path translation out into a seperate method. Added beginnings of a smoke test for AssetExportHtml.pm.
This commit is contained in:
parent
83dbcf63e9
commit
19bf1f4e8a
3 changed files with 179 additions and 19 deletions
80
t/Asset/AssetExportHtml.t
Normal file
80
t/Asset/AssetExportHtml.t
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
# load your modules here
|
||||
|
||||
use Test::More;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
## Test the url to path/file translation
|
||||
my $index = "home.html";
|
||||
my $urlMap = {
|
||||
'index.html' => {
|
||||
path => undef,
|
||||
filename => 'index.html',
|
||||
},
|
||||
|
||||
|
||||
'index.html/' => {
|
||||
path => undef,
|
||||
filename => 'index.html',
|
||||
},
|
||||
|
||||
'foo/page.html' => {
|
||||
path => 'foo',
|
||||
filename => 'page.html',
|
||||
},
|
||||
|
||||
|
||||
'foo' => {
|
||||
path => 'foo',
|
||||
filename => $index,
|
||||
},
|
||||
|
||||
'index.html/foo' => {
|
||||
path => 'foo',
|
||||
filename => $index,
|
||||
},
|
||||
|
||||
'index.html/foo.html' => {
|
||||
path => undef,
|
||||
filename => undef,
|
||||
},
|
||||
};
|
||||
|
||||
# two tests for each key in the urlMap hashRef plus any other tests that are added later.
|
||||
plan tests => (0 + scalar(keys %{$urlMap}) * 2);
|
||||
|
||||
foreach my $urlToTest ( keys %{$urlMap} ) {
|
||||
my $expectedPath = $urlMap->{$urlToTest}->{'path'};
|
||||
my $expectedFilename = $urlMap->{$urlToTest}->{'filename'};
|
||||
|
||||
# we need a dummy asset to test this private method.
|
||||
my $asset = WebGUI::Asset->newByPropertyHashRef($session,{className=>'WebGUI::Asset'});
|
||||
|
||||
# test this url
|
||||
my $dataRef = $asset->_translateUrlToPath($urlToTest, $index);
|
||||
my $returnedPath = $dataRef->{'path'};
|
||||
my $returnedFilename = $dataRef->{'filename'};
|
||||
|
||||
is ($returnedPath, $expectedPath, "path $expectedPath was returned for url $urlToTest");
|
||||
is ($returnedFilename, $expectedFilename, "filename $expectedFilename was returned for url $urlToTest");
|
||||
}
|
||||
|
||||
## Test something else
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue