Merge commit 'v7.10.17' into 8

Conflicts:
	docs/upgrades/upgrade_7.9.13-7.10.0.pl
	lib/WebGUI.pm
	lib/WebGUI/Asset/Template/TemplateToolkit.pm
	lib/WebGUI/Asset/Wobject/AssetReport.pm
	lib/WebGUI/Asset/Wobject/Thingy.pm
	lib/WebGUI/Form/Captcha.pm
	lib/WebGUI/Macro/AdminBar.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/PayDriver.pm
	lib/WebGUI/Shop/PayDriver/PayPal/ExpressCheckout.pm
	lib/WebGUI/Shop/PayDriver/PayPal/PayPalStd.pm
	lib/WebGUI/Shop/Transaction.pm
	lib/WebGUI/Workflow/Instance.pm
	lib/WebGUI/Workflow/Spectre.pm
	lib/WebGUI/i18n/English/PayDriver.pm
	t/Asset/Asset.t
	t/Asset/AssetExportHtml.t
	t/Asset/AssetLineage.t
	t/Asset/Wobject/Thingy.t
This commit is contained in:
Doug Bell 2011-06-17 20:13:41 -05:00
commit 795d88e7e5
69 changed files with 972 additions and 170 deletions

View file

@ -141,9 +141,25 @@ $canViewMaker->prepare(
},
);
plan tests => 114
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
;
#### TestAsset class to test definition / update relationship
BEGIN { $INC{ 'WebGUI/Asset/TestAsset.pm' } = __FILE__ }
package WebGUI::Asset::TestAsset;
our @ISA = ( 'WebGUI::Asset' );
sub definition {
my ( $class, $session, $definition ) = @_;
# Alter assetData fields for testing purposes. Do not do
# this in normal circumstances. Ever.
$definition = $class->SUPER::definition( $session, $definition );
# Make synopsis serialized
$definition->[0]->{properties}->{synopsis}->{serialize} = 1;
return $definition;
}
package main;
note "loadModule";
{
@ -863,4 +879,27 @@ sub getTitleTests {
);
}
subtest 'canAdd tolerates being called as an object method', sub {
my $class = 'WebGUI::Asset::Snippet';
my $snip = $tempNode->addChild({className => $class});
# Make a test user who's just in Turn Admin On
my $u = WebGUI::User->create($session);
WebGUI::Test->addToCleanup($u);
$u->addToGroups(['12']);
$session->user({ user => $u });
# default addGroup is Turn Admin On
ok $class->canAdd($session), 'can add when called as a class method';
ok $snip->canAdd($session), '...or an object method';
my $key = "assets/$class/addGroup";
WebGUI::Test->originalConfig($key);
$session->config->set($key, 3);
# now only admins can add snippets, so canAdd should return false
ok !$class->canAdd($session), 'Cannot add when called as a class method';
ok !$snip->canAdd($session), '...or an object method';
};
done_testing;

View file

@ -15,7 +15,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
use Test::More tests => 110; # increment this value for each test you create
use Test::More tests => 111; # increment this value for each test you create
use Test::Deep;
use Test::Exception;
use Data::Dumper;
@ -485,7 +485,7 @@ is($snippets[6]->getRank(), '5', 'setRank was able to set an arbitrary rank(lowe
$lineageIds = $folder->getLineage(['descendants']);
cmp_bag(\@snipIds, $lineageIds, 'setRank reordered the other siblings appropiately');
$snippets[6]->setRank('000007');
ok $snippets[6]->setRank('000007'), 'move snippet 6 to rank 7';
is($snippets[6]->getRank(), '7', 'setRank: move the Asset back (higher rank)');
@snipIds = map { $_->getId } @snippets;

View file

@ -17,8 +17,10 @@ use Scalar::Util qw( blessed );
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
use WebGUI::Asset::Shortcut;
use WebGUI::Asset::Snippet;
use Data::Dumper;
#----------------------------------------------------------------------------
# Init
@ -51,11 +53,12 @@ is(
"Original assetId is correct"
);
is_deeply(
[ $shortcut->getId ],
my $node = WebGUI::Asset->getImportNode( $session );
cmp_bag(
$original->exportGetRelatedAssetIds,
[ $shortcut->getId, $node->getId ],
'shortcut is related for the purpose of exports',
);
) or diag Dumper $original->exportGetRelatedAssetIds;
#----------------------------------------------------------------------------
# Test trashing snippet trashes shortcut also

View file

@ -243,11 +243,11 @@ cmp_deeply(
'getCrumbTrail: with topic set'
);
is_deeply(
cmp_bag(
$story->exportGetRelatedAssetIds,
[ $topic->getId ],
[ $topic->getId, $archive->getId ],
'exportGetRelatedAssetIds',
);
) or diag Dumper $story->exportGetRelatedAssetIds;
$story->topic('');

View file

@ -86,6 +86,13 @@ $ar->update( {
#----------------------------------------------------------------------------
# getTemplateVars
# Add a metadata variable to test
my $mdFieldId = $sn->addMetaDataField( undef, "TESTFIELD", undef, undef, "Text", );
WebGUI::Test->addToCleanup( sub{
WebGUI::Asset->getRoot( $session )->deleteMetaDataField( $mdFieldId )
} );
$sn->updateMetaData( $mdFieldId, "TESTVALUE" );
cmp_deeply(
$ar->getTemplateVars,
hash( {
@ -116,7 +123,7 @@ cmp_deeply(
'pagination.isFirstPage' => ignore(),
'pagination.nextPageText' => ignore(),
'pagination.firstPage' => ignore(),
'asset_loop' => [{ %{ $sn->get } }],
'asset_loop' => [{ %{ $sn->get }, %{ $sn->getMetaDataAsTemplateVariables } }],
} ),
"getTemplateVars returns complete and correct data structure",
);

View file

@ -17,7 +17,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 57;
plan tests => 53;
#----------------------------------------------------------------------------
# put your tests here

View file

@ -15,7 +15,7 @@ use strict;
use WebGUI::Test;
use WebGUI::Test::MockAsset;
use WebGUI::Session;
use Test::More tests => 39; # increment this value for each test you create
use Test::More tests => 47; # increment this value for each test you create
use Test::Deep;
use JSON;
use WebGUI::Asset::Wobject::Thingy;
@ -123,6 +123,7 @@ cmp_deeply(
field_loop=>[],
exportMetaData=>undef,
maxEntriesPerUser=>undef,
maxEntriesTotal=>undef,
},
'Getting newly added thing as JSON: www_getThingViaAjax returns correct data as JSON.'
);
@ -166,6 +167,7 @@ cmp_deeply(
canSearch=>1,
exportMetaData=>undef,
maxEntriesPerUser=>undef,
maxEntriesTotal=>undef,
}],
'Getting all things in Thingy as JSON: www_getThingsViaAjax returns correct data as JSON.'
);
@ -347,6 +349,56 @@ ok( $thingy->hasEnteredMaxPerUser($otherThingId), 'hasEnteredMaxPerUser returns
);
}
#################################################################
#
# maxEntriesTotal
#
#################################################################
my %otherThingProperties = %thingProperties;
$otherThingProperties{maxEntriesTotal} = 1;
$otherThingProperties{editTemplateId } = $templateId;
my $otherThingId = $thingy->addThing(\%otherThingProperties, 0);
my %otherFieldProperties = %fieldProperties;
$otherFieldProperties{thingId} = $otherThingId;
my $otherFieldId = $thingy->addField(\%otherFieldProperties, 0);
ok( ! $thingy->hasEnteredMaxEntries($otherThingId), 'hasEnteredMaxEntries: returns false with no data entered');
my @edit_thing_form_fields = qw/form_start form_end form_submit field_loop/;
{
$thingy->editThingData($otherThingId);
my %miniVars;
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
cmp_deeply(
\%miniVars,
{
form_start => ignore,
form_end => ignore,
form_submit => ignore,
field_loop => ignore,
},
'thing edit form variables exist, because max entries not reached yet'
);
}
$thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'other test value'} );
ok( $thingy->hasEnteredMaxEntries($otherThingId), 'hasEnteredMaxEntries returns true with one row entered, and maxEntriesTotal=1');
{
$thingy->editThingData($otherThingId);
my %miniVars;
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
my $existance = 0;
foreach my $tmplVar (@edit_thing_form_fields) {
$existance ||= exists $templateVars->{$tmplVar}
}
ok(
! $existance,
'thing edit form variables do not exist, because max entries was reached'
);
}
#################################################################
#
# deleteThing
@ -525,4 +577,27 @@ cmp_deeply(
) or diag( explain \@thingData );
#################################################################
#
# Unique fields
#
#################################################################
{
my %newThingProperties = %thingProperties;
$newThingProperties{'groupIdView'} = 3;
my $newThingId = $thingy->addThing(\%newThingProperties, 0);
my %newFieldProperties = %fieldProperties;
$newFieldProperties{thingId} = $newThingId;
$newFieldProperties{isUnique} = 1;
my $newFieldId = $thingy->addField(\%newFieldProperties, 0);
my $fieldValue = 'value 1';
my ($dataId,undef) = $thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => $fieldValue} );
ok( $thingy->isUniqueEntry($newThingId,"field_${newFieldId}",$fieldValue,$dataId), "unique if the same entry" );
ok( !$thingy->isUniqueEntry($newThingId,"field_${newFieldId}",$fieldValue,"new"), "new data is not unique" );
my ( undef, $errors ) = $thingy->editThingDataSave($newThingId, 'new', {"field_".$newFieldId => $fieldValue} );
ok( @$errors >= 1, "an error was returned" );
my $errorMessage = $i18n->get('needs to be unique error');
ok( grep( { $_->{error_message} =~ m/$errorMessage/ } @$errors), "error about uniqueness in right field" );
}

View file

@ -41,6 +41,7 @@ isa_ok($cereal, 'WebGUI::Serialize');
cmp_deeply(
$cereal->get,
{
_new => 1,
_dirty => 0,
someName => 'someName',
jsonField => [],

25
t/Macro/AssetProperty.t Normal file
View file

@ -0,0 +1,25 @@
use warnings;
use strict;
use Test::More tests => 8;
use FindBin;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Asset;
use WebGUI::Macro::AssetProperty;
my $session = WebGUI::Test->session;
my $temp = WebGUI::Asset->getTempspace($session);
my $props = $temp->get;
my ($url, $id) = @{$props}{qw(url assetId)};
sub proc { WebGUI::Macro::AssetProperty::process($session, @_) }
is proc($id, 'url'), $url, 'assetId';
is proc($url, 'assetId'), $id, 'url';
for my $name (qw(url assetId parentId lineage title menuTitle)) {
is proc($id, $name), $props->{$name}, "get $name";
}

97
t/Macro/RenderThingData.t Normal file
View file

@ -0,0 +1,97 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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::Test::MockAsset;
use WebGUI::Session;
use WebGUI::Asset::Template;
use WebGUI::Macro::RenderThingData;
use WebGUI::Asset::Wobject::Thingy;
use Test::More; # increment this value for each test you create
use Test::MockObject;
use Test::Deep;
my $templateId = lc 'VIEW_THING_DATA_TEMPL8T';
my $templateUrl = 'view_thing_data_template';
my $templateMock = WebGUI::Test::MockAsset->new('WebGUI::Asset::Template');
my $templateVars;
my $templateProcessed = 0;
$templateMock->mock('process', sub { $templateVars = $_[1]; $templateProcessed = 1; } );
my $session = WebGUI::Test->session;
$templateMock->mock_id( $templateId );
$templateMock->mock_url( $templateUrl );
plan tests => 4;
my $node = WebGUI::Test->asset;
my $thingy = $node->addChild({
className => 'WebGUI::Asset::Wobject::Thingy',
groupIdView => 7,
url => 'some_thing',
});
my %thingProperties = (
thingId => "THING_RECORD",
label => 'Label',
editScreenTitle => 'Edit',
editInstructions => 'instruction_edit',
groupIdAdd => '3',
groupIdEdit => '3',
saveButtonLabel => 'save',
afterSave => 'searchThisThing',
editTemplateId => "ThingyTmpl000000000003",
groupIdView => '7',
viewTemplateId => "ThingyTmpl000000000002",
defaultView => 'searchThing',
searchScreenTitle => 'Search',
searchDescription => 'description_search',
groupIdSearch => '7',
groupIdExport => '7',
groupIdImport => '7',
searchTemplateId => "ThingyTmpl000000000004",
thingsPerPage => 25,
);
my $thingId = $thingy->addThing(\%thingProperties);
my $field1Id = $thingy->addField({
thingId => $thingId,
fieldId => "new",
label => "textual",
dateCreated => time(),
fieldType => "text",
status => "editable",
display => 1,
displayInSearch => 1,
}, 0);
my ($thingDataId) = $thingy->editThingDataSave($thingId, 'new', {
thingDataId => 'new',
"field_$field1Id" => 'texty',
});
my $thing_url = $thingy->getUrl('thingId='.$thingId.';thingDataId='.$thingDataId);
my $output;
$output = WebGUI::Macro::RenderThingData::process($session, $thing_url);
like $output, qr/specify a template/, 'returns an error message if no template is offered';
ok !$templateProcessed, 'template not processed';
$templateProcessed = 0;
$output = WebGUI::Macro::RenderThingData::process($session, $thing_url, $templateId);
ok $templateProcessed, 'passed templateId, template processed';
$templateProcessed = 0;
$output = WebGUI::Macro::RenderThingData::process($session, $thing_url, $templateUrl);
ok $templateProcessed, 'passed template url, template processed';