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
|
|
@ -63,6 +63,9 @@ $creationDateSth->execute([$weekAgo, $weekStory->getId]);
|
|||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
WebGUI::Test->addToCleanup($versionTag);
|
||||
foreach my $asset ($archive1, $archive2) {
|
||||
$asset = $asset->cloneFromDb;
|
||||
}
|
||||
|
||||
my $workflow = WebGUI::Workflow->create($session,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ plan tests => 1; # increment this value for each test you create
|
|||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
||||
WebGUI::Test->addToCleanup(SQL => 'delete from passiveLog');
|
||||
WebGUI::Test->addToCleanup(SQL => 'delete from analyticRule');
|
||||
|
||||
my $workflow = WebGUI::Workflow->new($session, 'PassiveAnalytics000001');
|
||||
my $activities = $workflow->getActivities();
|
||||
##Note, they're in order, and the order is known.
|
||||
|
|
@ -30,6 +33,7 @@ my $instance = WebGUI::Workflow::Instance->create($session,
|
|||
priority => 1,
|
||||
}
|
||||
);
|
||||
WebGUI::Test->addToCleanup($instance);
|
||||
##Rule label, url, and regexp
|
||||
my @ruleSets = (
|
||||
['home', '/home', '^\/home' ],
|
||||
|
|
@ -76,12 +80,6 @@ PAUSE: while (my $retval = $instance->run()) {
|
|||
|
||||
ok(1, 'One test');
|
||||
|
||||
END {
|
||||
$session->db->write('delete from passiveLog');
|
||||
$session->db->write('delete from analyticRule');
|
||||
$instance->delete;
|
||||
}
|
||||
|
||||
sub loadLogData {
|
||||
my ($session, @urls) = @_;
|
||||
$session->db->write('delete from passiveLog');
|
||||
|
|
@ -99,3 +97,5 @@ sub loadLogData {
|
|||
$startTime += int(rand(10))+1;
|
||||
}
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ my $workflow = WebGUI::Workflow->create($session,
|
|||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
WebGUI::Test->addToCleanup($workflow);
|
||||
my $icalFetch = $workflow->addActivity('WebGUI::Workflow::Activity::CalendarUpdateFeeds');
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
|
|
@ -127,8 +128,4 @@ is(scalar @{ $newEvents }, 1, 'reimport does not create new children');
|
|||
$anniversary = pop @{ $newEvents };
|
||||
is($anniversary->get('description'), $party->get('description'), '... description, checks for line unwrapping');
|
||||
|
||||
END {
|
||||
$instance1 && $instance1->delete('skipNotify');
|
||||
$instance2 && $instance2->delete('skipNotify');
|
||||
$workflow && $workflow->delete;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ my $workflow = WebGUI::Workflow->create($session,
|
|||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
WebGUI::Test->addToCleanup($workflow);
|
||||
my $activity = $workflow->addActivity('WebGUI::Workflow::Activity::DeleteExpiredSessions');
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
|
|
@ -52,9 +53,6 @@ my $origSessionTimeout = $session->setting->get('sessionTimeout');
|
|||
my $sessionCount = $session->db->quickScalar('select count(*) from userSession');
|
||||
my $scratchCount = $session->db->quickScalar('select count(*) from userSessionScratch');
|
||||
|
||||
note $sessionCount;
|
||||
note $scratchCount;
|
||||
|
||||
my @sessions;
|
||||
|
||||
foreach (1..2) {
|
||||
|
|
@ -113,6 +111,4 @@ foreach my $testSession (@sessions) {
|
|||
## Make sure that one scratch session was deleted and the other kept.
|
||||
## Close and end all four sessions
|
||||
|
||||
END {
|
||||
$workflow->delete;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -158,7 +158,4 @@ is($session->db->quickScalar('select count(*) from Survey_response where Survey_
|
|||
# Afterwards, back to no incomplete responses
|
||||
is( scalar $session->db->buildArray($SQL), 0, 'Afterwards, back to no incomplete responses');
|
||||
|
||||
END {
|
||||
$session->db->write('delete from Survey_response where userId = ?', [$user->userId]) if $user;
|
||||
$survey->purge if $survey;
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ my $calendar = $temp->addChild(
|
|||
{ className => 'WebGUI::Asset::Wobject::Calendar' }
|
||||
);
|
||||
|
||||
my $one_year_ago = DateTime->today->subtract(years => 1)->ymd;
|
||||
my $eventStartDate = DateTime->today->truncate(to => 'month')->subtract(years => 1);
|
||||
|
||||
my $one_year_ago = $eventStartDate->ymd;
|
||||
|
||||
my $event = $calendar->addChild(
|
||||
{ className => 'WebGUI::Asset::Event',
|
||||
|
|
@ -43,7 +45,7 @@ my $recurId = $event->setRecurrence(
|
|||
{ recurType => 'monthDay',
|
||||
every => 2,
|
||||
startDate => $event->get('startDate'),
|
||||
dayNumber => DateTime->today->day,
|
||||
dayNumber => $eventStartDate->day,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@ use Test::More;
|
|||
use Test::Exception;
|
||||
use URI;
|
||||
|
||||
plan tests => 20; # increment this value for each test you create
|
||||
plan tests => 19; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
my $admin = $session->user;
|
||||
WebGUI::Test->addToCleanup(sub { WebGUI::Test->cleanupAdminInbox; });
|
||||
WebGUI::Test->addToCleanup(SQL => "delete from mailQueue where message like '%Threshold=15%'");
|
||||
my $inbox = WebGUI::Inbox->new($session);
|
||||
|
||||
my $import = WebGUI::Asset->getImportNode($session);
|
||||
|
|
@ -122,7 +124,7 @@ my $uri = URI->new($url);
|
|||
is($uri->path, $posters->getUrl, 'Link in message has correct URL path');
|
||||
is($uri->query, 'func=editVariant;vid='.$marilynVarId, 'Link in message has function and variant id');
|
||||
|
||||
wipeMessages($inbox, $admin);
|
||||
WebGUI::Test->cleanupAdminInbox;
|
||||
is(scalar @{$inbox->getMessagesForUser($admin)}, 0, 'All messages deleted');
|
||||
$instance1->delete;
|
||||
|
||||
|
|
@ -148,6 +150,13 @@ $message = $inbox->getMessagesForUser($admin)->[0];
|
|||
note "Test that the workflow does not die when encountering bad assets";
|
||||
|
||||
my $otherPosters = $posters->duplicate;
|
||||
WebGUI::Test->addToCleanup(sub {
|
||||
$session->db->write("delete from asset where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetData where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from sku where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from Product where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetIndex where assetId=?",[$otherPosters->getId]);
|
||||
});
|
||||
my $movie_posters = $import->addChild({
|
||||
className => 'WebGUI::Asset::Sku::Product',
|
||||
url => 'movie_posters',
|
||||
|
|
@ -181,7 +190,7 @@ is($retVal, 'done', 'Workflow is done');
|
|||
|
||||
$messages = $inbox->getMessagesForUser($admin);
|
||||
is(scalar @{$messages}, 1, 'Received one message');
|
||||
wipeMessages($inbox, $admin);
|
||||
WebGUI::Test->cleanupAdminInbox;
|
||||
|
||||
my $instance4 = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
|
|
@ -200,24 +209,5 @@ is($retVal, 'done', 'Workflow is done');
|
|||
|
||||
$messages = $inbox->getMessagesForUser($admin);
|
||||
is(scalar @{$messages}, 1, 'Still received one message');
|
||||
wipeMessages($inbox, $admin);
|
||||
|
||||
END {
|
||||
wipeMessages($inbox, $admin);
|
||||
$messages = $inbox->getMessagesForUser($admin);
|
||||
is(scalar @{$messages}, 0, 'Inbox cleaned up');
|
||||
$session->db->write("delete from mailQueue where message like '%Threshold=15%'");
|
||||
$session->db->write("delete from asset where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetData where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from sku where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from Product where assetId=?",[$otherPosters->getId]);
|
||||
$session->db->write("delete from assetIndex where assetId=?",[$otherPosters->getId]);
|
||||
}
|
||||
|
||||
sub wipeMessages {
|
||||
my ($inbox, $user) = @_;
|
||||
foreach my $message (@{ $inbox->getMessagesForUser($user) }) {
|
||||
$message->delete;
|
||||
}
|
||||
|
||||
}
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
103
t/Workflow/Activity/TrashExpiredEvents.t
Normal file
103
t/Workflow/Activity/TrashExpiredEvents.t
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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::Session;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Workflow::Activity::TrashExpiredEvents;
|
||||
use WebGUI::Asset;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
|
||||
plan tests => 5; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $bday = WebGUI::DateTime->new($session, WebGUI::Test->webguiBirthday)->cloneToUserTimeZone;
|
||||
my $now = WebGUI::DateTime->new($session, time())->cloneToUserTimeZone;
|
||||
my $tz = $session->datetime->getTimeZone();
|
||||
|
||||
my $root = WebGUI::Asset->getRoot($session);
|
||||
my $calendar = $root->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Calendar',
|
||||
title => 'Test Calendar',
|
||||
});
|
||||
my $wgBday = $calendar->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
title => 'WebGUI Birthday',
|
||||
startDate => $bday->toDatabaseDate,
|
||||
endDate => $bday->toDatabaseDate,
|
||||
timeZone => $tz,
|
||||
}, undef, undef, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
my $wrongBday = $calendar->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
title => 'Wrong Birthday',
|
||||
startDate => $bday->toDatabaseDate,
|
||||
endDate => $bday->toDatabaseDate,
|
||||
timeZone => $tz,
|
||||
}, undef, time()-5, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
$wrongBday->addRevision({
|
||||
startDate => $now->toDatabaseDate,
|
||||
endDate => $now->toDatabaseDate,
|
||||
}, undef, undef, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
my $nowEvent = $calendar->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
title => 'WebGUI Birthday',
|
||||
startDate => $now->toDatabaseDate,
|
||||
endDate => $now->toDatabaseDate,
|
||||
timeZone => $tz,
|
||||
}, undef, undef, {skipAutoCommitWorkflows => 1});
|
||||
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
WebGUI::Test->addToCleanup($tag);
|
||||
|
||||
my $workflow = WebGUI::Workflow->create($session,
|
||||
{
|
||||
enabled => 1,
|
||||
objectType => 'None',
|
||||
mode => 'realtime',
|
||||
},
|
||||
);
|
||||
WebGUI::Test->addToCleanup($workflow);
|
||||
my $eventNuker = $workflow->addActivity('WebGUI::Workflow::Activity::TrashExpiredEvents');
|
||||
$eventNuker->set('trashAfter', 3600);
|
||||
|
||||
my $instance1 = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
workflowId => $workflow->getId,
|
||||
skipSpectreNotification => 1,
|
||||
}
|
||||
);
|
||||
|
||||
my $retVal;
|
||||
|
||||
$retVal = $instance1->run();
|
||||
is($retVal, 'complete', 'cleanup: activity complete');
|
||||
$retVal = $instance1->run();
|
||||
is($retVal, 'done', 'cleanup: activity is done');
|
||||
$instance1->delete('skipNotify');
|
||||
|
||||
my $wgBdayCopy = $wgBday->cloneFromDb;
|
||||
my $nowEventCopy = $nowEvent->cloneFromDb;
|
||||
my $wrongBdayCopy = $wrongBday->cloneFromDb;
|
||||
|
||||
is $wgBdayCopy->get('state'), 'trash', 'old event was trashed';
|
||||
is $nowEventCopy->get('state'), 'published', 'recent event was left alone';
|
||||
is $wrongBdayCopy->get('state'), 'published', 'revisioned event was left alone';
|
||||
Loading…
Add table
Add a link
Reference in a new issue