Merge branch 'master' into survey

* master: (127 commits)
  Prefill in the email address in the ITransact credentials form from the user's Shop address.
  fixed Matrix best/worst rated lists
  Fix bad form variable for phone number in EMS Badge address info.
  - Added a switch to allow the use of non-WebGUI objects with the Workflow
  fixing a problem with previous survey fix
  fixed #9671: Survey - breaks admin bar
  fixed a Matrix sql problem
  i18n the image labels and title for the asset manager, manage screen.
  Prevent an imported package from changing the a current asset's status from pending to anything else.
  Remove trailing comma in Shop/Transaction JS so IE6 works.
  fixed documentation
  fixed a bug when a matrix listing didn't have a forum attached
  small char encoding fix to merged upgrade
  fix small issue in addChild
  adding merge point
  Fix a problem with purging an EMS.
  Update this template so that it passes the template i18n test.
  Fix a broken i18n label in answer edit template for the Survey.
  Unify all Survey CSS into 1 file, and use it.
  Adding/fixing Survey i18n and Help
  ...

Conflicts:
	lib/WebGUI/Asset/Wobject/Survey.pm
	lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm
	lib/WebGUI/i18n/English/Asset_Survey.pm
	www/extras/wobject/Survey/editsurvey/object.js
This commit is contained in:
Patrick Donelan 2009-02-10 07:57:42 +00:00
commit b0c5c09461
127 changed files with 5481 additions and 677 deletions

View file

@ -41,7 +41,7 @@ my $originalExportPath = $session->config->get('exportPath');
my $testRan = 1;
plan tests => 146; # Increment this number for each test you create
plan tests => 144; # Increment this number for each test you create
#----------------------------------------------------------------------------
# exportCheckPath()
@ -436,9 +436,6 @@ is($@, '', 'exportWriteFile for perl file works');
ok(-e $asset->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actually writes the perl file");
eval { $content = WebGUI::Test->getPage($asset, 'exportHtml_view') };
is(scalar $asset->exportGetUrlAsPath->absolute->slurp, $content, "exportWriteFile puts correct content in exported perl file");
$guidPath->rmtree;
$asset = WebGUI::Asset->new($session, 'ExportTest000000000002');
eval { $asset->exportWriteFile() };
@ -446,9 +443,6 @@ is($@, '', 'exportWriteFile for plain file works');
ok(-e $asset->exportGetUrlAsPath->absolute->stringify, "exportWriteFile actuall writes the plain file");
eval { $content = WebGUI::Test->getPage($asset, 'exportHtml_view') };
is(scalar $asset->exportGetUrlAsPath->absolute->slurp, $content, "exportWriteFile puts correct content in exported plain file");
$guidPath->rmtree;
# next, make sure an exception is thrown if the user we're exporting as doesn't
@ -933,7 +927,7 @@ SKIP: {
eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) };
is($@, '', "exportAsHtml catches inaccessible exportPath ");
is($success, 0, "exportAsHtml returns 0 for inaccessible exportPath");
is($message, "can't access " . $inaccessibleDirectory->stringify, "exportAsHtml returns correct message for inaccessible exportPath");
is($message, "can't create exportPath " . $inaccessibleDirectory->stringify, "exportAsHtml returns correct message for inaccessible exportPath");
}
# exportPath is a file, not a directory

View file

@ -21,6 +21,7 @@ use Test::More;
use Test::Deep;
use Scalar::Util;
use WebGUI::Asset::File::GalleryFile::Photo;
use WebGUI::International;
#----------------------------------------------------------------------------
# Init
@ -268,7 +269,7 @@ like(
"www_editCommentSave -- Permission denied if not Gallery->canAddComment",
);
my $i18n = $photo->i18n($session);
my $i18n = WebGUI::International->new($session, 'Asset_Photo');
my $errorMessage;
# Required: commentId

View file

@ -32,7 +32,7 @@ my $session = WebGUI::Test->session;
my $formClass = 'WebGUI::Form::CheckList';
my $formType = 'Checkbox';
my $numTests = 20;
my $numTests = 23;
plan tests => $numTests;
@ -61,19 +61,22 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org');
is(scalar @forms, 1, '1 form was parsed to test basic functionality');
my @inputs = $forms[0]->inputs;
is(scalar @inputs, 3, 'The form has 3 inputs');
is(scalar @inputs, 4, 'The form has 3 inputs');
#Basic tests
is($inputs[0]->name, 'CList1', 'Checking input name for checkbox 1');
is($inputs[0]->type, 'checkbox', 'Checking input type for checkbox 1');
is($inputs[0]->value, 'foo', 'Checking default value for checkbox 1');
is($inputs[1]->name, 'CList1', 'Checking input name for checkbox 2');
is($inputs[1]->type, 'checkbox', 'Checking input type for checkbox 2');
is($inputs[1]->value, undef, 'Checking default value for checkbox 2');
is($inputs[2]->name, 'CList1', 'Checking input name for checkbox 3');
is($inputs[2]->type, 'checkbox', 'Checking input type for checkbox 3');
is($inputs[2]->value, undef, 'Checking default value for checkbox 3');
is($inputs[0]->name, '__CList1_isIn', 'Checking input name for hidden element');
is($inputs[0]->type, 'hidden', 'Checking input type for hidden element');
is($inputs[0]->value, '1', 'Checking default value for hidden element');
is($inputs[1]->name, 'CList1', 'Checking input name for checkbox 1');
is($inputs[1]->type, 'checkbox', 'Checking input type for checkbox 1');
is($inputs[1]->value, 'foo', 'Checking default value for checkbox 1');
is($inputs[2]->name, 'CList1', 'Checking input name for checkbox 2');
is($inputs[2]->type, 'checkbox', 'Checking input type for checkbox 2');
is($inputs[2]->value, undef, 'Checking default value for checkbox 2');
is($inputs[3]->name, 'CList1', 'Checking input name for checkbox 3');
is($inputs[3]->type, 'checkbox', 'Checking input type for checkbox 3');
is($inputs[3]->value, undef, 'Checking default value for checkbox 3');
@ -92,10 +95,10 @@ my $html = join "\n",
is(scalar @forms, 1, '1 form was parsed to test showSelectAll');
@inputs = $forms[0]->inputs;
is(scalar @inputs, 4, 'The form has 4 inputs (1 button + 3 checkboxes)');
is(scalar @inputs, 5, 'The form has 5 inputs (1 hidden, 1 button, 3 checkboxes)');
is($inputs[0]->type, 'button', 'The Select All button is there and before all checkboxes');
is( $inputs[0]->{value},
is($inputs[1]->type, 'button', 'The Select All button is there and before all checkboxes');
is( $inputs[1]->{value},
WebGUI::International->new($session,"Form_CheckList")->get("selectAll label"),
'The value is internationalized'
);

View file

@ -89,7 +89,7 @@ is(scalar @forms, 1, '1 form was parsed');
my $form = $forms[0];
#use Data::Dumper;
my @inputs = $form->inputs;
is(scalar @inputs, 6, 'The form has 6 inputs');
is(scalar @inputs, 7, 'The form has 7 inputs');
#Basic tests

View file

@ -19,40 +19,51 @@ use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
use LWP::MediaTypes;
my $recentModule = $LWP::MediaTypes::VERSION > 5.800;
my @testSets = (
{
input => 'webgui.txt',
output => 'text/plain',
input => 'webgui.txt',
newput => 'text/plain',
oldput => 'text/plain',
comment => q|text|,
},
{
input => 'plainblack.gif',
output => 'image/gif',
input => 'plainblack.gif',
newput => 'image/gif',
oldput => 'image/gif',
comment => q|gif|,
},
{
input => 'background.jpg',
output => 'image/jpeg',
input => 'background.jpg',
newput => 'image/jpeg',
oldput => 'image/jpeg',
comment => q|jpeg|,
},
{
input => 'colorPicker.js',
output => 'application/octet-stream',
input => 'colorPicker.js',
newput => 'application/x-javascript',
oldput => 'application/octet-stream',
comment => q|javascript|,
},
{
input => 'favIcon.ico',
output => 'application/octet-stream',
input => 'favIcon.ico',
newput => 'image/vnd.microsoft.icon',
oldput => 'application/octet-stream',
comment => q|octet-stream for unknown type|,
},
{
input => '',
output => 'application/octet-stream',
input => '',
newput => 'application/octet-stream',
oldput => 'application/octet-stream',
comment => q|Null path returns application/octet-stream|,
},
{
input => undef,
output => undef,
input => undef,
newput => undef,
oldput => undef,
comment => q|Undef path returns undef|,
},
);
@ -75,7 +86,8 @@ foreach my $testSet (@testSets) {
? join '/', WebGUI::Test->root, 'www/extras', $testSet->{input}
: $testSet->{input};
my $output = WebGUI::Macro::FetchMimeType::process($session, $file);
is($output, $testSet->{output}, $testSet->{comment} );
my $expected = $recentModule ? $testSet->{newput} : $testSet->{oldput};
is($output, $expected, $testSet->{comment} );
}
}

17
t/POD.t
View file

@ -20,14 +20,23 @@ use File::Spec;
plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
my $threshold = $ENV{POD_COVERAGE} ? 0.75 : 0;
my @modules = ();
find(\&countModules, File::Spec->catdir( WebGUI::Test->lib, 'WebGUI' ) );
my $moduleCount = scalar(@modules);
plan tests => $moduleCount;
foreach my $package (sort @modules) {
my $pc = Pod::Coverage->new(package=>$package);
ok($pc->coverage, $package);
my $pc = Pod::Coverage->new(
package=>$package,
also_private => [ qr/definition/ ],
);
my $coverage = $pc->coverage > $threshold;
my $goodReason = $pc->why_unrated() eq 'no public symbols defined';
SKIP: {
skip "No subroutines found by Devel::Symdump for $package", 1 if $goodReason;
ok($coverage, sprintf "%s has %d%% POD coverage", $package, $pc->coverage*100);
}
}
@ -41,7 +50,3 @@ sub countModules {
$package =~ s/\//::/g;
push(@modules,$package);
}

View file

@ -286,7 +286,7 @@ my @forms = HTML::Form->parse($html, 'http://www.webgui.org');
is (scalar @forms, 1, 'getEditForm generates just 1 form');
my @inputs = $forms[0]->inputs;
is (scalar @inputs, 11, 'getEditForm: the form has 11 controls');
is (scalar @inputs, 13, 'getEditForm: the form has 13 controls');
my @interestingFeatures;
foreach my $input (@inputs) {
@ -334,6 +334,10 @@ cmp_deeply(
name => 'groupToUse',
type => 'option',
},
{
name => '__groupToUse_isIn',
type => 'hidden',
},
{
name => 'receiptEmailTemplateId',
type => 'option',
@ -342,6 +346,10 @@ cmp_deeply(
name => 'saleNotificationGroupId',
type => 'option',
},
{
name => '__saleNotificationGroupId_isIn',
type => 'hidden',
},
],
'getEditForm made the correct form with all the elements'

View file

@ -126,7 +126,7 @@ cmp_deeply(
#
#######################################################################
my $driver;
$driver;
my $options = {
label => 'flat rate, ship weight, items in the cart',
@ -320,13 +320,17 @@ is($driver->calculate($cart), 30_200, 'calculate by percentage of price');
#----------------------------------------------------------------------------
# Cleanup
END {
if (defined $driver and ref $driver eq 'WebGUI::Shop::ShipDriver::FlatRate') {
if (defined $driver && ref $driver eq 'WebGUI::Shop::ShipDriver::FlatRate') {
$driver->delete;
}
if (defined $cart and ref $cart eq 'WebGUI::Shop::Cart') {
if (defined $cart && ref $cart eq 'WebGUI::Shop::Cart') {
$cart->delete;
}
if (defined $car and (ref($car) eq 'WebGUI::Asset::Sku::Product')) {
if (defined $car && (ref($car) eq 'WebGUI::Asset::Sku::Product')) {
$car->purge;
}
my $tag = WebGUI::VersionTag->getWorking($session, 'nocreate');
if (defined $tag) {
$tag->rollback;
}
}

93
t/hardcodedExtras.t Normal file
View file

@ -0,0 +1,93 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2007 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 warnings;
use lib "$FindBin::Bin/lib"; ##t/lib
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Asset::Template;
use WebGUI::Asset::Snippet;
#The goal of this test is to find hard coded extras paths in templates or in
#the extraHeadTags of any assets.
use Test::More; # increment this value for each test you create
my $numTests = 0;
plan skip_all => 'set CODE_COP to enable this test' unless $ENV{CODE_COP};
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;
my $hardcodedExtras = qr!(?:href|src)=.\^?/[(;]?extras/!;
# put your tests here
my @hardcodedExtras;
my $getATemplate = WebGUI::Asset::Template->getIsa($session);
TEMPLATE: while (my $templateAsset = $getATemplate->()) {
my $template = $templateAsset->get('template');
next TEMPLATE unless $template;
if ($template =~ m!$hardcodedExtras! ) {
push @hardcodedExtras, {
url => $templateAsset->getUrl,
id => $templateAsset->getId,
title => $templateAsset->getTitle,
type => 'Template',
}
}
}
my $getASnippet = WebGUI::Asset::Snippet->getIsa($session);
SNIPPET: while (my $snippetAsset = $getASnippet->()) {
my $snippet = $snippetAsset->get('snippet');
next SNIPPET unless $snippet;
if ($snippet =~ m!$hardcodedExtras! ) {
push @hardcodedExtras, {
url => $snippetAsset->getUrl,
id => $snippetAsset->getId,
title => $snippetAsset->getTitle,
type => 'Snippet',
}
}
}
my $getAnAsset = WebGUI::Asset->getIsa($session);
ASSET: while (my $asset = $getAnAsset->()) {
my $headTags = $asset->get('extraHeadTags');
next ASSET unless $headTags;
if ($headTags =~ m!$hardcodedExtras! ) {
push @hardcodedExtras, {
url => $asset->getUrl,
id => $asset->getId,
title => $asset->getTitle,
type => 'Asset',
}
}
}
$numTests = scalar @hardcodedExtras;
if ($numTests) {
plan tests => $numTests;
}
else {
plan tests => 1;
ok(1, 'All assets pass');
}
foreach my $template ( @hardcodedExtras ) {
fail(
sprintf "%s with hardcoded extras url: %s, id: %s, url: %s", @{ $template }{qw/type title id url/}
);
}

View file

@ -79,7 +79,7 @@ while (my $templateAsset = $getATemplate->()) {
}
}
$numTests = scalar @templateLabels | scalar @questionableTemplates;
$numTests = scalar @templateLabels + scalar @questionableTemplates;
plan tests => $numTests;

View file

@ -96,6 +96,8 @@ sub violates {
my @arguments = _get_args($arg_list);
my $namespace;
if ($arguments[1]) {
my $secondArgument = $arguments[1]->[0];
return unless $secondArgument->isa('PPI::Token::Quote');
$namespace = $arguments[1]->[0]->string;
}
else {
@ -114,7 +116,11 @@ sub violates {
##constructing arguments for the get call.
return if exists $arguments[0]->[1] and $arguments[0]->[1]->isa('PPI::Token::Operator');
return unless $arguments[0]->[0]->isa('PPI::Token::Quote');
my $label = $arguments[0]->[0]->string;
my $firstArgument = $arguments[0]->[0];
my $label = $firstArgument->string;
##Can't do variable interpolation
return if $firstArgument->isa('PPI::Token::Quote::Double')
&& $label =~ /\$/;
my $namespace = $self->{_i18n_objects}->{$symbol_name};
if ($arguments[1]) {
$namespace = $arguments[1]->[0]->string;

132
t/splitTag.t Normal file
View file

@ -0,0 +1,132 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2008 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::HTML;
use WebGUI::Session;
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
# the style param below refers to how the callis made. the function has two optional params
# by testing with each style we can test the default for thsee params.
# also array/scalar return type are tested.
# call type = 1: all three params; return array
# call type = 2: only tag and text; return scalar
# call type = 3: only text and count; return array
# call type = 4: only the text; return scalar
my @testArray = (
{
inputText => q!<p>First Paragraph</p> <p>Second Paragraph</p>!,
output => q!First Paragraph!,
style => 1,
tag => 'p',
count => 1,
comment => 'get one paragraph, no defaults',
},
{
inputText => q!<p>First Paragraph</p> <p>Second Paragraph</p>!,
output => q!First Paragraph!,
style => 4,
tag => 'p',
count => 1,
comment => 'get one paragraph, all defaults',
},
{
inputText => q!<p>First Paragraph</p> <p>Second Paragraph</p>!,
output => q!First Paragraph;Second Paragraph!,
style => 1,
tag => 'p',
count => -1,
comment => 'get all paragraphs, no defaults',
},
{
inputText => q!<p>First Paragraph</p> <p>Second Paragraph</p>!,
output => q!First Paragraph;Second Paragraph!,
style => 3,
tag => 'p',
count => -1,
comment => 'get all paragraphs, default tag',
},
{
inputText => q!<p> </p><p>First nonblank Paragraph</p> <p>Second Paragraph</p>!,
output => q!First nonblank Paragraph!,
style => 4,
tag => 'p',
count => -1,
comment => 'get nonblank paragraph, all defaults',
},
{
inputText => q!<p> &nbsp;</p><p>First nonblank Paragraph</p> <p>Second Paragraph</p>!,
output => q!First nonblank Paragraph!,
style => 4,
tag => 'p',
count => -1,
comment => 'get nonblank(nbsp) paragraph, all defaults',
},
{
inputText => q!<li>First List Item</li> <li>Second List Item</li> <li>Third List Item</li>!,
output => q!First List Item;Second List Item;Third List Item!,
style => 1,
tag => 'li',
count => -1,
comment => 'get all list items, no defaults',
},
{
inputText => q!<li>First List Item</li> <li>Second List Item</li> <li>Third List Item</li>!,
output => q!First List Item;Second List Item!,
style => 1,
tag => 'li',
count => 2,
comment => 'get first 2 list items, no defaults',
},
{
inputText => q!<tr><td>First Item</td> <td>Second Item</td></tr>!,
output => q!First Item Second Item!,
style => 1,
tag => 'tr',
count => -1,
comment => 'get table row ignore table data',
},
{
inputText => q!<tr><td>First Item</td> <td>Second Item</td></tr>!,
output => q!First Item;Second Item!,
style => 1,
tag => 'td',
count => -1,
comment => 'get table data ignore table row',
},
);
my $numTests = scalar @testArray;
plan tests => $numTests;
my $output;
foreach my $testSet (@testArray) {
if( $testSet->{style} == 1 ) {
$output = join ';',WebGUI::HTML::splitTag($testSet->{tag},$testSet->{inputText}, $testSet->{count});
} elsif( $testSet->{style} == 2 ) {
$output = WebGUI::HTML::splitTag($testSet->{tag},$testSet->{inputText});
} elsif( $testSet->{style} == 3 ) {
$output = join ';', WebGUI::HTML::splitTag($testSet->{inputText}, $testSet->{count});
} elsif( $testSet->{style} == 4 ) {
$output = WebGUI::HTML::splitTag($testSet->{inputText});
}
is($output, $testSet->{output}, $testSet->{comment});
}

View file

@ -53,12 +53,12 @@ my @templateLabels;
while (my $templateAsset = $getATemplate->()) {
my $template = $templateAsset->get('template');
my $header = $templateAsset->get('headBlock');
my $header = $templateAsset->get('extraHeadTags');
my $match = ($template =~ $macro);
if ($header) {
$match ||= ($header =~ $macro);
}
ok(!$match, sprintf "%s: (%s) has no bad gateway macros", $templateAsset->getTitle, $templateAsset->getId);
ok(!$match, sprintf "%s: %s (%s) has no bad gateway macros", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
}