Merge branch 'master' into 8-merge
Conflicts: docs/gotcha.txt lib/WebGUI.pm lib/WebGUI/Asset.pm lib/WebGUI/Asset/File/GalleryFile/Photo.pm lib/WebGUI/Asset/Post.pm lib/WebGUI/Asset/Story.pm lib/WebGUI/Asset/Template.pm lib/WebGUI/Asset/Wobject/Calendar.pm lib/WebGUI/Asset/Wobject/GalleryAlbum.pm lib/WebGUI/Asset/Wobject/Navigation.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/AssetTrash.pm lib/WebGUI/Config.pm lib/WebGUI/Form/Template.pm lib/WebGUI/Group.pm lib/WebGUI/Inbox.pm lib/WebGUI/Workflow/Activity/DeleteExpiredSessions.pm lib/WebGUI/Workflow/Activity/TrashExpiredEvents.pm sbin/testEnvironment.pl t/AdSpace.t t/AdSpace/Ad.t t/Asset/Asset.t t/Asset/AssetExportHtml.t t/Asset/AssetLineage.t t/Asset/EMSSubmissionForm.t t/Asset/Event.t t/Asset/File/GalleryFile/Photo/00base.t t/Asset/File/GalleryFile/Photo/comment.t t/Asset/File/GalleryFile/Photo/download.t t/Asset/File/GalleryFile/Photo/edit.t t/Asset/File/GalleryFile/Photo/exif.t t/Asset/File/GalleryFile/Photo/makeResolutions.t t/Asset/File/GalleryFile/Photo/makeShortcut.t t/Asset/File/Image/setfile.t t/Asset/File/setfile.t t/Asset/Post.t t/Asset/Post/Thread/getAdjacentThread.t t/Asset/Sku.t t/Asset/Sku/ProductCollateral.t t/Asset/Story.t t/Asset/Template.t t/Asset/Template/HTMLTemplateExpr.t t/Asset/Wobject/Gallery/00base.t t/Asset/Wobject/GalleryAlbum/00base.t t/Asset/Wobject/GalleryAlbum/ajax.t t/Asset/Wobject/GalleryAlbum/delete.t t/Asset/Wobject/Matrix.t t/Asset/Wobject/StoryArchive.t t/Asset/Wobject/Survey/ExpressionEngine.t t/Asset/Wobject/Survey/Reports.t t/AssetAspect/RssFeed.t t/Auth/mech.t t/Config.t t/Group.t t/Help/isa.t t/International.t t/Mail/Send.t t/Operation/AdSpace.t t/Operation/Auth.t t/Pluggable.t t/Session.t t/Session/DateTime.t t/Session/ErrorHandler.t t/Session/Scratch.t t/Session/Stow.t t/Shop/Cart.t t/Shop/Pay.t t/Shop/PayDriver/ITransact.t t/Shop/PayDriver/PayPalStd.t t/Shop/Ship.t t/Shop/ShipDriver.t t/Shop/TaxDriver/EU.t t/Shop/TaxDriver/Generic.t t/Shop/Transaction.t t/Shop/Vendor.t t/VersionTag.t t/Workflow/Activity/ArchiveOldStories.t t/Workflow/Activity/ExpireIncompleteSurveyResponses.t t/lib/WebGUI/Test.pm
This commit is contained in:
commit
babfa74209
238 changed files with 4557 additions and 1287 deletions
175
t/Asset/Asset.t
175
t/Asset/Asset.t
|
|
@ -35,7 +35,144 @@ my $session = WebGUI::Test->session;
|
|||
|
||||
my @getTitleTests = getTitleTests($session);
|
||||
|
||||
plan tests => 121
|
||||
my $rootAsset = WebGUI::Asset->getRoot($session);
|
||||
|
||||
##Test users.
|
||||
##All users in here will be deleted at the end of the test. DO NOT PUT
|
||||
##Visitor or Admin in here!
|
||||
my %testUsers = ();
|
||||
##Just a regular user
|
||||
$testUsers{'regular user'} = WebGUI::User->new($session, 'new');
|
||||
$testUsers{'regular user'}->username('regular user');
|
||||
##Users in group 12 can add Assets
|
||||
$testUsers{'canAdd turnOnAdmin'} = WebGUI::User->new($session, 'new');
|
||||
$testUsers{'canAdd turnOnAdmin'}->addToGroups(['12']);
|
||||
$testUsers{'canAdd turnOnAdmin'}->username('Turn On Admin user');
|
||||
|
||||
##Just a user for owning assets
|
||||
$testUsers{'owner'} = WebGUI::User->new($session, 'new');
|
||||
$testUsers{'owner'}->username('Asset Owner');
|
||||
|
||||
##Test Groups
|
||||
##All groups in here will be deleted at the end of the test
|
||||
my %testGroups = ();
|
||||
##A group and user for groupIdEdit
|
||||
$testGroups{'canEdit asset'} = WebGUI::Group->new($session, 'new');
|
||||
$testUsers{'canEdit group user'} = WebGUI::User->new($session, 'new');
|
||||
$testUsers{'canEdit group user'}->addToGroups([$testGroups{'canEdit asset'}->getId]);
|
||||
$testUsers{'canEdit group user'}->username('Edit Group User');
|
||||
addToCleanup($testGroups{'canEdit asset'});
|
||||
|
||||
##A group and user for groupIdEdit
|
||||
$testGroups{'canAdd asset'} = WebGUI::Group->new($session, 'new');
|
||||
$testUsers{'canAdd group user'} = WebGUI::User->new($session, 'new');
|
||||
$testUsers{'canAdd group user'}->addToGroups([$testGroups{'canAdd asset'}->getId]);
|
||||
$testUsers{'canEdit group user'}->username('Can Add Group User');
|
||||
addToCleanup($testGroups{'canAdd asset'}, values %testUsers);
|
||||
|
||||
my $canAddMaker = WebGUI::Test::Maker::Permission->new();
|
||||
$canAddMaker->prepare({
|
||||
'className' => 'WebGUI::Asset',
|
||||
'session' => $session,
|
||||
'method' => 'canAdd',
|
||||
#'pass' => [3, $testUsers{'canAdd turnOnAdmin'}, $testUsers{'canAdd group user'} ],
|
||||
'pass' => [3, $testUsers{'canAdd group user'} ],
|
||||
'fail' => [1, $testUsers{'regular user'}, ],
|
||||
});
|
||||
|
||||
my $canAddMaker2 = WebGUI::Test::Maker::Permission->new();
|
||||
$canAddMaker2->prepare({
|
||||
'className' => 'WebGUI::Asset',
|
||||
'session' => $session,
|
||||
'method' => 'canAdd',
|
||||
'fail' => [$testUsers{'canAdd turnOnAdmin'},],
|
||||
});
|
||||
|
||||
my $properties;
|
||||
$properties = {
|
||||
# '1234567890123456789012'
|
||||
id => 'canEditAsset0000000010',
|
||||
title => 'canEdit Asset Test',
|
||||
url => 'canEditAsset1',
|
||||
className => 'WebGUI::Asset',
|
||||
ownerUserId => $testUsers{'owner'}->userId,
|
||||
groupIdEdit => $testGroups{'canEdit asset'}->getId,
|
||||
groupIdView => 7,
|
||||
};
|
||||
|
||||
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($versionTag2);
|
||||
|
||||
my $canEditAsset = $rootAsset->addChild($properties, $properties->{id});
|
||||
|
||||
$versionTag2->commit;
|
||||
$properties = {}; ##Clear out the hash so that it doesn't leak later by accident.
|
||||
|
||||
my $canEditMaker = WebGUI::Test::Maker::Permission->new();
|
||||
$canEditMaker->prepare({
|
||||
'object' => $canEditAsset,
|
||||
'method' => 'canEdit',
|
||||
'pass' => [3, $testUsers{'owner'}, $testUsers{'canEdit group user'}, ],
|
||||
'fail' => [1, $testUsers{'regular user'}, ],
|
||||
});
|
||||
|
||||
my $versionTag3 = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($versionTag3);
|
||||
$properties = {
|
||||
# '1234567890123456789012'
|
||||
id => 'canViewAsset0000000010',
|
||||
title => 'canView Asset Test',
|
||||
url => 'canViewAsset1',
|
||||
className => 'WebGUI::Asset',
|
||||
ownerUserId => $testUsers{'owner'}->userId,
|
||||
groupIdEdit => $testGroups{'canEdit asset'}->getId,
|
||||
groupIdView => $testGroups{'canEdit asset'}->getId,
|
||||
};
|
||||
|
||||
|
||||
my $canViewAsset = $rootAsset->addChild($properties, $properties->{id});
|
||||
|
||||
$versionTag3->commit;
|
||||
$properties = {}; ##Clear out the hash so that it doesn't leak later by accident.
|
||||
|
||||
my $canViewMaker = WebGUI::Test::Maker::Permission->new();
|
||||
$canViewMaker->prepare(
|
||||
{
|
||||
'object' => $canEditAsset,
|
||||
'method' => 'canView',
|
||||
'pass' => [1, 3, $testUsers{'owner'}, $testUsers{'canEdit group user'}, $testUsers{'regular user'},],
|
||||
},
|
||||
{
|
||||
'object' => $canViewAsset,
|
||||
'method' => 'canView',
|
||||
'pass' => [3, $testUsers{'owner'}, $testUsers{'canEdit group user'}, ],
|
||||
'fail' => [1, $testUsers{'regular user'}, ],
|
||||
},
|
||||
);
|
||||
|
||||
#### 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;
|
||||
|
||||
plan tests => 132
|
||||
+ scalar(@fixIdTests)
|
||||
+ scalar(@fixTitleTests)
|
||||
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
|
||||
;
|
||||
|
||||
|
|
@ -186,6 +323,40 @@ isa_ok($tempNode, 'WebGUI::Asset::Wobject::Folder');
|
|||
is($tempNode->getId, 'tempspace0000000000000', 'Tempspace Asset ID check');
|
||||
is($tempNode->getParent->getId, $rootAsset->getId, 'Tempspace parent is Root Asset');
|
||||
|
||||
|
||||
################################################################
|
||||
#
|
||||
# update
|
||||
#
|
||||
################################################################
|
||||
|
||||
# Create a new TestAsset instance
|
||||
my $ta = $importNode->addChild( {
|
||||
className => 'WebGUI::Asset::TestAsset',
|
||||
} );
|
||||
isa_ok( $ta, 'WebGUI::Asset::TestAsset', 'addChild returns correct object' );
|
||||
|
||||
ok(
|
||||
eval { $ta->update({ synopsis => [ "one", "two" ] }); 1; },
|
||||
'update() succeeds with ref on serialized property',
|
||||
);
|
||||
cmp_deeply(
|
||||
$ta->get('synopsis'),
|
||||
[ "one", "two" ],
|
||||
"serialized property returns deserialized ref",
|
||||
);
|
||||
|
||||
ok(
|
||||
eval { $ta->update({ synopsis => '[ "two", "three" ]', }); 1; },
|
||||
'update() succeeds with serialized string on serialized property',
|
||||
);
|
||||
cmp_deeply(
|
||||
$ta->get('synopsis'),
|
||||
[ "two", "three" ],
|
||||
"serialized property returns deserialized ref",
|
||||
);
|
||||
$ta->purge;
|
||||
|
||||
################################################################
|
||||
#
|
||||
# urlExists
|
||||
|
|
@ -801,3 +972,5 @@ sub getTitleTests {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue