';
}
if ($isSecondary) {
return _submenu($session,{workarea => $i18n->get(978)});
diff --git a/lib/WebGUI/PassiveProfiling.pm b/lib/WebGUI/PassiveProfiling.pm
index 01c46fa01..5f5e84eb0 100644
--- a/lib/WebGUI/PassiveProfiling.pm
+++ b/lib/WebGUI/PassiveProfiling.pm
@@ -61,7 +61,7 @@ sub add {
[
$session->id->generate(), $session->user->userId,
$session->var->get("sessionId"), $assetId,
- $session->datetime->time(),
+ time(),
]);
return undef;
}
diff --git a/lib/WebGUI/Session/DateTime.pm b/lib/WebGUI/Session/DateTime.pm
index 2230aabd4..1dab2cb20 100644
--- a/lib/WebGUI/Session/DateTime.pm
+++ b/lib/WebGUI/Session/DateTime.pm
@@ -950,7 +950,7 @@ sub setToEpoch {
}
unless ($dt) {
$self->session->errorHandler->warn("Could not format date $set for epoch. Returning current time");
- return $self->time();
+ return time();
}
return $dt->epoch;
}
@@ -959,7 +959,8 @@ sub setToEpoch {
=head2 time ( )
-Returns an epoch date for now.
+DEPRECATED - This method is deprecated, and should not be used in new code. Use
+the perl built in function time().
=cut
diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm
index fe6a2daf1..750b68d4a 100644
--- a/lib/WebGUI/Session/Url.pm
+++ b/lib/WebGUI/Session/Url.pm
@@ -193,7 +193,7 @@ sub gateway {
my $url = $self->session->config->get("gateway").'/'.$pageUrl;
$url =~ s/\/+/\//g;
if ($self->session->setting->get("preventProxyCache") == 1 and !$skipPreventProxyCache) {
- $url = $self->append($url,"noCache=".randint(0,1000).':'.$self->session->datetime->time());
+ $url = $self->append($url,"noCache=".randint(0,1000).':'.time());
}
if ($pairs) {
$url = $self->append($url,$pairs);
diff --git a/lib/WebGUI/Session/Var.pm b/lib/WebGUI/Session/Var.pm
index d472c0cab..00eb08f7f 100644
--- a/lib/WebGUI/Session/Var.pm
+++ b/lib/WebGUI/Session/Var.pm
@@ -184,14 +184,14 @@ sub new {
$self->session->{_sessionId} = $self->{_var}{sessionId};
return $self;
}
- if ($self->{_var}{expires} && $self->{_var}{expires} < $session->datetime->time()) { ##Session expired, start a new one with the same Id
+ if ($self->{_var}{expires} && $self->{_var}{expires} < time()) { ##Session expired, start a new one with the same Id
$self->end;
$self->start(1,$sessionId);
}
elsif ($self->{_var}{sessionId} ne "") { ##Fetched an existing session. Update variables with recent data.
- $self->{_var}{lastPageView} = $session->datetime->time();
+ $self->{_var}{lastPageView} = time();
$self->{_var}{lastIP} = $session->env->getIp;
- $self->{_var}{expires} = $session->datetime->time() + $session->setting->get("sessionTimeout");
+ $self->{_var}{expires} = time() + $session->setting->get("sessionTimeout");
$self->session->{_sessionId} = $self->{_var}{sessionId};
$session->db->setRow("userSession","sessionId",$self->{_var});
return $self;
@@ -241,7 +241,7 @@ sub start {
$userId = 1 if ($userId eq "");
my $sessionId = shift;
$sessionId = $self->session->id->generate if ($sessionId eq "");
- my $time = $self->session->datetime->time();
+ my $time = time();
$self->{_var} = {
expires => $time + $self->session->setting->get("sessionTimeout"),
lastPageView => $time,
diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm
index 0008a94ce..cab115996 100644
--- a/lib/WebGUI/User.pm
+++ b/lib/WebGUI/User.pm
@@ -544,9 +544,9 @@ sub friends {
$myFriends->isEditable(0);
$self->uncache;
$self->{_user}{"friendsGroup"} = $myFriends->getId;
- $self->{_user}{"lastUpdated"} = $self->session->datetime->time();
+ $self->{_user}{"lastUpdated"} = time();
$self->session->db->write("update users set friendsGroup=?, lastUpdated=? where userId=?",
- [$myFriends->getId, $self->session->datetime->time(), $self->userId]);
+ [$myFriends->getId, time(), $self->userId]);
$self->{_friendsGroup} = $myFriends;
}
@@ -642,7 +642,7 @@ sub getGroups {
my $withoutExpired = shift;
my $clause = "";
if ($withoutExpired) {
- $clause = "and expireDate>".$self->session->datetime->time();
+ $clause = "and expireDate>".time();
}
my $gotGroupsForUser = $self->session->stow->get("gotGroupsForUser");
if (exists $gotGroupsForUser->{$self->userId}) {
@@ -1016,7 +1016,7 @@ sub karma {
$self->uncache;
$self->{_user}{karma} += $amount;
$self->session->db->write("update users set karma=karma+? where userId=?", [$amount, $self->userId]);
- $self->session->db->write("insert into karmaLog values (?,?,?,?,?)",[$self->userId, $amount, $source, $description, $self->session->datetime->time()]);
+ $self->session->db->write("insert into karmaLog values (?,?,?,?,?)",[$self->userId, $amount, $source, $description, time()]);
}
return $self->{_user}{karma};
}
diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm
index 2ddc5d10b..a3c28e596 100644
--- a/lib/WebGUI/VersionTag.pm
+++ b/lib/WebGUI/VersionTag.pm
@@ -137,7 +137,7 @@ sub create {
my $properties = shift;
my $tagId = $session->db->setRow("assetVersionTag","tagId",{
tagId=>"new",
- creationDate=>$session->datetime->time(),
+ creationDate=>time(),
createdBy=>$session->user->userId
});
my $tag = $class->new($session, $tagId);
@@ -178,7 +178,7 @@ sub commit {
if ($finished) {
$self->{_data}{isCommitted} = 1;
$self->{_data}{committedBy} = $self->session->user->userId unless ($self->{_data}{committedBy});
- $self->{_data}{commitDate} = $self->session->datetime->time();
+ $self->{_data}{commitDate} = time();
$self->session->db->setRow("assetVersionTag", "tagId", $self->{_data});
$self->clearWorking;
return 1;
@@ -674,7 +674,7 @@ sub set {
my $self = shift;
my $properties = shift;
- my $now = $self->session->datetime->time();
+ my $now = time();
my $startTime = WebGUI::DateTime->new($self->session,$now)->toDatabase;
my $endTime = WebGUI::DateTime->new($self->session,'2036-01-01 00:00:00')->toDatabase;
diff --git a/lib/WebGUI/Workflow/Activity/ArchiveOldStories.pm b/lib/WebGUI/Workflow/Activity/ArchiveOldStories.pm
index 1e337b016..ef1ef36d5 100644
--- a/lib/WebGUI/Workflow/Activity/ArchiveOldStories.pm
+++ b/lib/WebGUI/Workflow/Activity/ArchiveOldStories.pm
@@ -71,7 +71,7 @@ See WebGUI::Workflow::Activity::execute() for details.
sub execute {
my $self = shift;
my $session = $self->session;
- my $epoch = $self->session->datetime->time();
+ my $epoch = time();
my $getAnArchive = WebGUI::Asset::Wobject::StoryArchive->getIsa($session);
ARCHIVE: while (my $archive = $getAnArchive->()) {
next ARCHIVE unless $archive && $archive->get("archiveAfter");
diff --git a/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm b/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm
index 68dc2bd59..c55c66420 100644
--- a/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm
+++ b/lib/WebGUI/Workflow/Activity/ArchiveOldThreads.pm
@@ -69,7 +69,7 @@ See WebGUI::Workflow::Activity::execute() for details.
sub execute {
my $self = shift;
- my $epoch = $self->session->datetime->time();
+ my $epoch = time();
my $a = $self->session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::Collaboration'");
while (my ($assetId) = $a->array) {
my $cs = WebGUI::Asset->new($self->session, $assetId, "WebGUI::Asset::Wobject::Collaboration");
diff --git a/lib/WebGUI/Workflow/Activity/ExpireUnvalidatedEmailUsers.pm b/lib/WebGUI/Workflow/Activity/ExpireUnvalidatedEmailUsers.pm
index 50ba7697f..55c8a518d 100644
--- a/lib/WebGUI/Workflow/Activity/ExpireUnvalidatedEmailUsers.pm
+++ b/lib/WebGUI/Workflow/Activity/ExpireUnvalidatedEmailUsers.pm
@@ -81,7 +81,7 @@ sub execute {
return $self->COMPLETE;
}
- my @userIds = $self->session->db->buildArray("SELECT a.userId FROM authentication AS a INNER JOIN users AS u ON a.userId = u.userId WHERE a.authMethod = 'WebGUI' AND a.fieldName = 'emailValidationKey' AND u.status = 'Deactivated' AND u.dateCreated < ?", [$self->session->datetime->time - $self->get('interval')]);
+ my @userIds = $self->session->db->buildArray("SELECT a.userId FROM authentication AS a INNER JOIN users AS u ON a.userId = u.userId WHERE a.authMethod = 'WebGUI' AND a.fieldName = 'emailValidationKey' AND u.status = 'Deactivated' AND u.dateCreated < ?", [time - $self->get('interval')]);
foreach my $userId (@userIds) {
WebGUI::User->new($self->session, $userId)->delete;
}
diff --git a/lib/WebGUI/Workflow/Activity/WaitUntil.pm b/lib/WebGUI/Workflow/Activity/WaitUntil.pm
index 911cc95ec..42a66de91 100644
--- a/lib/WebGUI/Workflow/Activity/WaitUntil.pm
+++ b/lib/WebGUI/Workflow/Activity/WaitUntil.pm
@@ -84,7 +84,7 @@ sub execute {
my $urlOfSingleAsset = "";
#By default, we'll make it so that things happen now.
- my $time = $session->datetime->time();
+ my $time = time();
#If the type is startTime, we'll wait until the version tag starttime to proceed
if($self->get("type") eq "startTime") {
@@ -98,7 +98,7 @@ sub execute {
my $dt = WebGUI::DateTime->new($session,$time);
#Get the current UTC time
- my $now = WebGUI::DateTime->new($session,$session->datetime->time());
+ my $now = WebGUI::DateTime->new($session,time());
#Workflow is complete if the time has passed.
if($now->epoch >= $dt->epoch) {
diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm
index 170eedc82..ad2d4d40c 100644
--- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm
+++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm
@@ -1293,11 +1293,21 @@ the preview is displayed, the Post can either be edited or canceled.|,
lastUpdated => 1149655722,
},
- 'user.isVisitor' => {
+ 'post_loop_user.isVisitor' => {
message => q|A conditional that is true if the poster is a visitor.|,
lastUpdated => 1149655722,
},
+ 'user.isVisitor' => {
+ message => q|A conditional that is true if the current user is a visitor.|,
+ lastUpdated => 1149655722,
+ },
+
+ 'hideProfileUrl' => {
+ message => q|A conditional that is true if the poster is a visitor, or the current user is a visitor. In the first case, Visitor's profile is not visible to any user. In the second case, Visitor is not allowed to view any user's profile|,
+ lastUpdated => 1254506340,
+ },
+
'edit.url' => {
message => q|The URL to edit this Post.|,
lastUpdated => 1149655722,
@@ -1359,6 +1369,11 @@ user has an avatar.|,
lastUpdated => 1149655722,
},
+ 'lastReply.hideProfileUrl' => {
+ message => q|A conditional that is true if the poster of the last reply is a visitor, or the current user is a visitor. In the first case, Visitor's profile is not visible to any user. In the second case, Visitor is not allowed to view any user's profile|,
+ lastUpdated => 1254506340,
+ },
+
'lastReply.username' => {
message => q|The name of user who submitted the last reply.|,
lastUpdated => 1149655722,
diff --git a/lib/WebGUI/i18n/English/Asset_Template.pm b/lib/WebGUI/i18n/English/Asset_Template.pm
index 5b4319033..f381d584e 100644
--- a/lib/WebGUI/i18n/English/Asset_Template.pm
+++ b/lib/WebGUI/i18n/English/Asset_Template.pm
@@ -33,9 +33,9 @@ our $I18N = {
},
'template error' => {
- message => q|There is a syntax error in this template, %s, %s. Please correct.|,
+ message => q|There is a syntax error in this template, %s, %s, %s. Please correct.|,
context => q|Error when executing template|,
- lastUpdated => 1244476530,
+ lastUpdated => 1254512327,
},
'namespace description' => {
diff --git a/sbin/changeIobStatus.pl b/sbin/changeIobStatus.pl
index 777898af0..e42b76b6a 100755
--- a/sbin/changeIobStatus.pl
+++ b/sbin/changeIobStatus.pl
@@ -74,7 +74,7 @@ if ($userMessageFile) {
print "Searching for users with a status of $currentStatus ...\n" unless ($quiet);
my $userList;
-my $now = $session->datetime->time();
+my $now = time();
my $inbox = WebGUI::Inbox->new($session);
my $sth = $session->db->read("select userId,assetId from InOutBoard_status where status=?",[$currentStatus]);
while (my ($userId,$assetId) = $sth->array) {
diff --git a/sbin/userImport.pl b/sbin/userImport.pl
index 3e547bc0c..c70ddfa42 100755
--- a/sbin/userImport.pl
+++ b/sbin/userImport.pl
@@ -213,7 +213,7 @@ sub calculateExpireOffset {
}
}
if ($units eq "fixed") {
- my $seconds = (($offset - $session->datetime->time()));
+ my $seconds = (($offset - time()));
if ($seconds < 1) {
return undef;
}
diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t
index c3342dff9..aaca25101 100644
--- a/t/Asset/Asset.t
+++ b/t/Asset/Asset.t
@@ -815,67 +815,83 @@ is($iufpAsset2->get('url'), 'inheriturlfromparent01/iufp2', '... update works pr
################################################################
#
-# requestAutoCommit to move uncommitted child to uncommitted parent
+# addRevision to uncommitted child of uncommitted parent
#
################################################################
my $versionTag5 = WebGUI::VersionTag->getWorking($session);
-WebGUI::Test->tagsToRollback($versionTag5);
-$versionTag5->set( { name => 'move commit of child to uncommitted parent on requestAutoCommit tests vt1' } );
+$versionTag5->set( { name => 'move revision of uncommitted child to uncommitted parent tests vt1' } );
$properties = {
+
# '1234567890123456789012'
- id => 'moveVersionToParent_01',
- title => 'moveVersionToParent_01',
- className => 'WebGUI::Asset::Wobject::Layout',
- url => 'moveVersionToParent_01',
+ id => 'moveVersionToParent_01',
+ title => 'moveVersionToParent_01',
+ className => 'WebGUI::Asset::Wobject::Layout',
+ url => 'moveVersionToParent_01',
};
-my $parentAsset = $defaultAsset->addChild($properties, $properties->{id});
-my $parentVersionTag = WebGUI::VersionTag->new($session, $parentAsset->get('tagId'));
-is($parentVersionTag->get('isCommitted'),0, 'built non-committed parent asset');
+my $parentAsset = $defaultAsset->addChild( $properties, $properties->{id}, undef, { skipAutoCommitWorkflows => 1 } );
+my $parentVersionTag = WebGUI::VersionTag->new( $session, $parentAsset->get('tagId') );
+is( $parentVersionTag->get('isCommitted'), 0, 'built non-committed parent asset' );
-
-my $versionTag6 = WebGUI::VersionTag->create($session, {});
-WebGUI::Test->tagsToRollback($versionTag6);
-$versionTag6->set( { name => 'move commit of child to uncommitted parent on requestAutoCommit tests vt2' } );
+my $versionTag6 = WebGUI::VersionTag->create( $session, {} );
+$versionTag6->set( { name => 'move revision of uncommitted child to uncommitted parent tests vt2' } );
$versionTag6->setWorking;
$properties2 = {
+
# '1234567890123456789012'
- id => 'moveVersionToParent_03',
- title => 'moveVersionToParent_03',
- className => 'WebGUI::Asset::Wobject::Layout',
- url => 'moveVersionToParent_03',
+ id => 'moveVersionToParent_03',
+ title => 'moveVersionToParent_03',
+ className => 'WebGUI::Asset::Wobject::Layout',
+ url => 'moveVersionToParent_03',
};
-my $childAsset = $parentAsset->addChild($properties, $properties2->{id});
-my $testAsset = WebGUI::Asset->newPending($session, $childAsset->get('parentId'));
-my $testVersionTag = WebGUI::VersionTag->new($session, $testAsset->get('tagId'));
+my $childAsset = $parentAsset->addChild(
+ $properties2, $properties2->{id},
+ time(),
+ { skipAutoCommitWorkflows => 1 }
+);
+my $testAsset = WebGUI::Asset->newPending( $session, $childAsset->get('parentId') );
+my $testVersionTag = WebGUI::VersionTag->new( $session, $testAsset->get('tagId') );
my $childVersionTag;
-$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
-is($childVersionTag->get('isCommitted'),0, 'built non-committed child asset');
+$childVersionTag = WebGUI::VersionTag->new( $session, $childAsset->get('tagId') );
+is( $childVersionTag->get('isCommitted'), 0, 'built non-committed child asset' );
-isnt($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have different version tags');
-isnt($testVersionTag->getId,$childVersionTag->getId,'parent asset and child asset version tags unmatched');
+is( $testAsset->get('tagId'),
+ $childAsset->get('tagId'),
+ 'uncommitted parent asset and uncommitted child asset have same version tag at addChild'
+);
-eval {
- $childAsset->requestAutoCommit;
- $childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
+$properties2 = {
+
+ # '1234567890123456789012'
+ id => 'moveVersionToParent_03',
+ title => 'moveVersionToParent_03a',
+ className => 'WebGUI::Asset::Wobject::Layout',
+ url => 'moveVersionToParent_03a',
};
-is($childVersionTag->get('isCommitted'),0, 'confirm non-committed child asset');
+sleep 2;
+$childAsset->addRevision( $properties2, time(), { skipAutoCommitWorkflows => 1 } );
-is($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have same version tags');
+is( $parentVersionTag->get('isCommitted'), 0, 'confimr non-committed parent asset after revision' );
+is( $childVersionTag->get('isCommitted'), 0, 'confirm non-committed child asset after revision' );
-eval {
- $testVersionTag->commit;
-};
+is( $testAsset->get('tagId'),
+ $childAsset->get('tagId'),
+ 'uncommitted parent asset and uncommitted child asset have same version tag after addRevision'
+);
-is($testVersionTag->get('isCommitted'),1,'parent asset is now committed');
+eval { $testVersionTag->commit; };
-$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
-is($childVersionTag->get('isCommitted'),1,'child asset is now committed');
+$session->log->warn('parent asset is now committed');
+is( $testVersionTag->get('isCommitted'), 1, 'parent asset is now committed' );
+
+$childVersionTag = WebGUI::VersionTag->new( $session, $childAsset->get('tagId') );
+$session->log->warn('child asset is now committed');
+is( $childVersionTag->get('isCommitted'), 1, 'child asset is now committed' );
################################################################
#
diff --git a/t/Asset/Post.t b/t/Asset/Post.t
index 81fa89265..ec495ae1a 100644
--- a/t/Asset/Post.t
+++ b/t/Asset/Post.t
@@ -8,13 +8,6 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
-# XXX I (chrisn) started this file to test the features I added to the
-# Collaboration / Post system for 7.5, but didn't have the time available to me
-# to do a full test suite for the Post Wobject. This means that this test suite
-# is *largely incomplete* and should be finished. What is here *is* the
-# following:
-#
-#
# 1. The basic framework for a test suite for the Post Asset.
# Includes setup, cleanup, boilerplate, etc. Basically the really boring,
# repetitive parts of the test that you don't want to write yourself.
@@ -26,7 +19,7 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
-use Test::More tests => 9; # increment this value for each test you create
+use Test::More tests => 16; # increment this value for each test you create
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Post::Thread;
@@ -114,7 +107,11 @@ ok($post->canEdit(), "User in groupToEditPost group can edit post after the time
$session->user({userId => $groupIdEditUser->userId});
ok($post->canEdit(), "User in groupIdEditUserGroup group can edit post after the timeout");
+######################################################################
+#
# getSynopsisAndContent
+#
+######################################################################
my ($synopsis, $content) = $post->getSynopsisAndContent('', q|Brandheiße Neuigkeiten rund um's Klettern für euch aus der Region |);
is($synopsis, q|Brandheiße Neuigkeiten rund um's Klettern für euch aus der Region |, 'getSynopsisAndContent: UTF8 characters okay');
@@ -132,9 +129,40 @@ is($synopsis, q|less than < greater than >|, '... HTML escaped characters
($synopsis, $content) = $post->getSynopsisAndContent('', q|
less than < greater than >
|);
is($synopsis, q|less than < greater than >|, '... HTML entities decoded by HTML::splitTag');
-TODO: {
- local $TODO = "Tests to make later";
- ok(0, 'Whole lot more work to do here');
-}
+######################################################################
+#
+# getTemplateVars
+#
+######################################################################
+
+my $versionTag2 = WebGUI::VersionTag->getWorking($session);
+my $post1 = $collab->addChild({
+ className => 'WebGUI::Asset::Post::Thread',
+ content => 'hello, world!',
+ ownerUserId => 3,
+}, @addArgs);
+my $post2 = $collab->addChild({
+ className => 'WebGUI::Asset::Post::Thread',
+ content => 'hello, world!',
+ ownerUserId => 1,
+}, @addArgs);
+$versionTag2->commit();
+WebGUI::Test->tagsToRollback($versionTag);
+my $variables;
+$session->user({userId => 1});
+$variables = $post1->getTemplateVars();
+is( $variables->{'ownerUserId'}, 3, 'first post owned by admin');
+ok( $variables->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
+$variables = $post2->getTemplateVars();
+is( $variables->{'ownerUserId'}, 1, 'first post owned by admin');
+ok( $variables->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
+
+$session->user({userId => 3});
+$variables = $post1->getTemplateVars();
+is( $variables->{'ownerUserId'}, 3, 'first post owned by admin');
+ok( !$variables->{'hideProfileUrl'}, 'show profile url');
+$variables = $post2->getTemplateVars();
+is( $variables->{'ownerUserId'}, 1, 'first post owned by admin');
+ok( $variables->{'hideProfileUrl'}, 'hide profile url, since poster is visitor');
# vim: syntax=perl filetype=perl
diff --git a/t/Asset/Template/packed.t b/t/Asset/Template/packed.t
index 851937302..4d547d37d 100644
--- a/t/Asset/Template/packed.t
+++ b/t/Asset/Template/packed.t
@@ -25,6 +25,10 @@ use CSS::Packer;
use JavaScript::Packer;
use WebGUI::Asset::Template;
+if ( !$ENV{CODE_COP} ) {
+ plan skip_all => "Set CODE_COP to enable these tests";
+}
+
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
@@ -32,6 +36,7 @@ my $templates = WebGUI::Asset->getRoot( $session )
->getLineage( ['descendants'], {
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
} );
+WebGUI::Test->tagsToRollback( WebGUI::VersionTag->getWorking( $session ) );
#----------------------------------------------------------------------------
# Tests
@@ -66,9 +71,4 @@ for my $templateId ( @$templates ) {
}
-#----------------------------------------------------------------------------
-# Cleanup
-END {
- WebGUI::VersionTag->getWorking( $session )->rollback;
-}
#vim:ft=perl
diff --git a/t/Asset/Wobject/Collaboration/templateVariables.t b/t/Asset/Wobject/Collaboration/templateVariables.t
new file mode 100644
index 000000000..c71790d45
--- /dev/null
+++ b/t/Asset/Wobject/Collaboration/templateVariables.t
@@ -0,0 +1,92 @@
+# vim:syntax=perl
+#-------------------------------------------------------------------
+# 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
+#------------------------------------------------------------------
+
+# Test the Collaboration system template variables
+#
+#
+
+use FindBin;
+use strict;
+use lib "$FindBin::Bin/../../../lib";
+use WebGUI::Test; # Must use this before any other WebGUI modules
+use Test::More;
+use Test::Deep;
+use Data::Dumper;
+use WebGUI::Session;
+
+#----------------------------------------------------------------------------
+# Tests
+plan tests => 20; # Increment this number for each test you create
+
+#----------------------------------------------------------------------------
+# Init
+my $session = WebGUI::Test->session;
+my @addChildArgs = ( {skipAutoCommitWorkflows=>1} );
+my $collab = WebGUI::Asset->getImportNode( $session )->addChild({
+ className => 'WebGUI::Asset::Wobject::Collaboration',
+ threadsPerPage => 20,
+ displayLastReply => 1,
+});
+
+my @threads = (
+ $collab->addChild( {
+ className => 'WebGUI::Asset::Post::Thread',
+ title => "X - Foo",
+ isSticky => 0,
+ ownerUserId => 1,
+ }, undef, 1, @addChildArgs),
+ $collab->addChild( {
+ className => 'WebGUI::Asset::Post::Thread',
+ title => "X - Bar",
+ isSticky => 0,
+ ownerUserId => 3,
+ }, undef, 2, @addChildArgs),
+);
+
+$_->setSkipNotification for @threads; # 100+ messages later...
+my $versionTag = WebGUI::VersionTag->getWorking( $session );
+$versionTag->commit;
+WebGUI::Test->tagsToRollback($versionTag);
+
+my $templateVars;
+my $posts;
+$session->user({userId => 3});
+$templateVars = $collab->getViewTemplateVars();
+
+##Threads come in reverse order, most recent first
+$posts = $templateVars->{post_loop};
+is( $posts->[1]->{'ownerUserId'}, 1, 'first post owned by visitor');
+ok( $posts->[1]->{'user.isVisitor'}, 'first post made by visitor');
+ok( $posts->[1]->{'hideProfileUrl'}, 'hide profile url, since post made by visitor');
+ok( $posts->[1]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
+ok( $posts->[1]->{'lastReply.hideProfileUrl'}, 'lastReply show profile url, since post not made by visitor, and user is not visitor');
+is( $posts->[0]->{'ownerUserId'}, 3, 'second post owned by admin');
+ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
+ok( !$posts->[0]->{'hideProfileUrl'}, 'show profile url, since post made by admin, and user is not visitor');
+ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
+ok( !$posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply show profile url, since post not made by visitor, and user is not visitor');
+
+$session->user({userId => 1});
+$templateVars = $collab->getViewTemplateVars();
+
+##Threads come in reverse order, most recent first
+$posts = $templateVars->{post_loop};
+is( $posts->[1]->{'ownerUserId'}, 1, 'first post owned by visitor');
+ok( $posts->[1]->{'user.isVisitor'}, 'first post made by visitor');
+ok( $posts->[1]->{'hideProfileUrl'}, 'hide profile url, since current user is visitor');
+ok( $posts->[1]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
+ok( $posts->[1]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
+is( $posts->[0]->{'ownerUserId'}, 3, 'second post owned by admin');
+ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
+ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
+ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
+ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
+#vim:ft=perl
diff --git a/t/Asset/Wobject/DataForm.t b/t/Asset/Wobject/DataForm.t
index e268db0b5..0d3d7ab1e 100644
--- a/t/Asset/Wobject/DataForm.t
+++ b/t/Asset/Wobject/DataForm.t
@@ -36,6 +36,12 @@ my $df = WebGUI::Asset->getImportNode( $session )
fieldConfiguration => '[]',
} );
+my $dform = WebGUI::Asset->getDefault($session)->addChild({
+ className => "WebGUI::Asset::Wobject::DataForm",
+ mailData => 0,
+});
+$dform->createField('gotCaptcha', { type => 'Captcha', name => 'humanCheck', });
+
my $versionTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->tagsToRollback($versionTag);
$versionTag->commit;
@@ -43,7 +49,7 @@ $versionTag->commit;
#----------------------------------------------------------------------------
# Tests
-plan tests => 1; # Increment this number for each test you create
+plan tests => 4; # Increment this number for each test you create
#----------------------------------------------------------------------------
# _createForm
@@ -60,4 +66,26 @@ $df->_createForm(
is($WebGUI::Test::logger_error, "Unable to load form control - MASSIVE FORM FAILURE", '_createForm logs when it cannot load a form type');
+#----------------------------------------------------------------------------
+# getContentLastModified
+
+sleep 3;
+
+$df->{_mode} = 'form';
+is($df->getContentLastModified, $df->get('lastModified'), 'getContentLastModified: form normally returns lastModified');
+$df->{_mode} = 'list';
+cmp_ok(
+ $df->getContentLastModified,
+ '>',
+ $df->get('lastModified'),
+ '... form in list mode does not return lastModified'
+);
+$dform->{_mode} = 'form';
+cmp_ok(
+ $dform->getContentLastModified,
+ '>',
+ $dform->get('lastModified'),
+ '... form with a captcha does not return lastModified, even in form mode'
+);
+
#vim:ft=perl
diff --git a/t/Asset/Wobject/Survey.t b/t/Asset/Wobject/Survey.t
index 05a7fdc4f..113277888 100644
--- a/t/Asset/Wobject/Survey.t
+++ b/t/Asset/Wobject/Survey.t
@@ -18,18 +18,13 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
-my $tests = 46;
-plan tests => $tests + 1;
+plan tests => 47;
#----------------------------------------------------------------------------
# put your tests here
-my $usedOk = use_ok('WebGUI::Asset::Wobject::Survey');
my ($survey);
-SKIP: {
-
-skip $tests, "Unable to load Survey" unless $usedOk;
my $user = WebGUI::User->new( $session, 'new' );
WebGUI::Test->usersToDelete($user);
my $import_node = WebGUI::Asset->getImportNode($session);
@@ -252,7 +247,6 @@ cmp_deeply(from_json($surveyEnd), { type => 'forward', url => '/getting_started'
is($survey->responseJSON->nextResponseSection()->{text}, 'new text', '..wheras the original response uses the original text');
}
-}
# Test visualization
eval 'use GraphViz';
@@ -314,3 +308,13 @@ cmp_deeply(
],
"Admin console submenu",
);
+
+####################################################
+#
+# www_loadSurvey
+#
+####################################################
+
+my $survey_json = $survey->www_loadSurvey({});
+my $survey_data = JSON::from_json($survey_json);
+unlike($survey_data->{edithtml}, qr/\^International/, 'www_loadSurvey process macros');
diff --git a/t/Asset/Wobject/SyndicatedContent.t b/t/Asset/Wobject/SyndicatedContent.t
index cec27fb6b..d0845ad43 100644
--- a/t/Asset/Wobject/SyndicatedContent.t
+++ b/t/Asset/Wobject/SyndicatedContent.t
@@ -20,13 +20,12 @@ use Data::Dumper;
use WebGUI::Test;
use WebGUI::Session;
-use Test::More tests => 19; # increment this value for each test you create
+use Test::More tests => 20; # increment this value for each test you create
use WebGUI::Asset::Wobject::SyndicatedContent;
use XML::FeedPP;
my $session = WebGUI::Test->session;
my %var;
-my (@rss_feeds);
##############################
## SETUP ##
@@ -37,6 +36,7 @@ my $node = WebGUI::Asset->getImportNode($session);
# Create a version tag to work in
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"SyndicatedContent Test"});
+WebGUI::Test->tagsToRollback($versionTag);
my $syndicated_content = $node->addChild({className=>'WebGUI::Asset::Wobject::SyndicatedContent'});
##############################
@@ -106,8 +106,35 @@ cmp_ok(scalar(@{$var->{item_loop}}), '>', 0, 'the item loop has items');
my $processed_template = eval {$syndicated_content->processTemplate($var,undef,$template) };
ok($processed_template, "A response was received from processTemplate.");
-END {
- # Clean up after thy self
- $versionTag->rollback();
-}
+####################################################################
+#
+# getTemplateVariables
+#
+####################################################################
+##Construct a feed with no description, so the resulting template variables can
+##be checked for an undef description
+my $feed = XML::FeedPP->new(<
+
+Revision Log - /WebGUI/
+
+
+
+
+1970-01-01T00:53:41
+
+12312 - Ready for 7.7.20 development.
+
+
+
+colin
+
+https://svn.webgui.org/svnweb/plainblack/revision?rev=12312
+1970-01-01T00:53:41
+1970-01-01T00:53:41
+
+EOFEED
+
+my $vars = $syndicated_content->getTemplateVariables($feed);
+ok( defined $vars->{item_loop}->[0]->{description}, 'getTemplateVariables: description is not undefined');
diff --git a/t/Group.t b/t/Group.t
index 61dd929e3..d1cf801c4 100644
--- a/t/Group.t
+++ b/t/Group.t
@@ -75,7 +75,7 @@ my @ipTests = (
);
-plan tests => (152 + scalar(@scratchTests) + scalar(@ipTests)); # increment this value for each test you create
+plan tests => (151 + scalar(@scratchTests) + scalar(@ipTests)); # increment this value for each test you create
my $session = WebGUI::Test->session;
my $testCache = WebGUI::Cache->new($session, 'myTestKey');
@@ -660,10 +660,6 @@ ok( !$cacheDude->isInGroup($gB->getId), "Cache dude is not a member of group B")
##Admin group inclusion check.
-my $vgroup = WebGUI::Group->new($session, 1);
-my $vgroups = $vgroup->getGroupsIn();
-ok( isIn(3, @{ $vgroups }), 'Admin Group is in Group Visitor');
-
SKIP: {
skip("need to test expiration date in groupings interacting with recursive or not", 1);
ok(undef, "expiration date in groupings for getUser");
diff --git a/t/PassiveProfiling.t b/t/PassiveProfiling.t
index 4ff7820d1..0afe76f69 100644
--- a/t/PassiveProfiling.t
+++ b/t/PassiveProfiling.t
@@ -23,7 +23,7 @@ use WebGUI::Asset;
use Test::More;
use Test::Deep;
-my $startingTime = $session->datetime->time();
+my $startingTime = time();
my $numTests = 5; # increment this value for each test you create
plan tests => 1 + $numTests;
@@ -77,7 +77,7 @@ is($count, 0, 'add: Nothing added if passive profiling is not enabled');
$session->setting->set('passiveProfilingEnabled', 1);
my $timeLogged;
-$timeLogged = $session->datetime->time();
+$timeLogged = time();
WebGUI::PassiveProfiling::add( $session, $page->getId );
my $count = $session->db->quickScalar('select count(*) from passiveProfileLog where assetId=? and dateOfEntry >= ?',[$page->getId, $startingTime]);
diff --git a/t/Storage.t b/t/Storage.t
index cac8dd8eb..caabc8be5 100644
--- a/t/Storage.t
+++ b/t/Storage.t
@@ -91,10 +91,8 @@ is($guidStorage->getDirectoryId, $newGuid, '... getDirectoryId');
#
####################################################
-my $savecdn = $session->config->get('cdn');
-if ($savecdn) {
- $session->config->delete('cdn');
-}
+WebGUI::Test->originalConfig('cdn');
+$session->config->delete('cdn');
# Note: the CDN configuration will be reverted after CDN tests below
my $storageDir1 = join '/', $uploadDir, '7e', '8a', '7e8a1b6a';
@@ -530,10 +528,7 @@ my $cdnCfg = {
"syncProgram" => "cp -r -- '%s' $cdnTestPath/",
"deleteProgram" => "rm -r -- '$cdnTestPath/%s' > /dev/null 2>&1"
};
-my ($addedCdnQ, $addedCdnU);
-$addedCdnQ = mkdir $cdnCfg->{'queuePath'} unless -e $cdnCfg->{'queuePath'};
my $dest = substr($cdnCfg->{'url'}, 7);
-$addedCdnU = mkdir $dest unless -e $dest;
$session->config->set('cdn', $cdnCfg);
my $cdnUrl = $cdnCfg->{'url'};
my $cdnUlen = length $cdnUrl;
@@ -715,11 +710,4 @@ END {
) {
ref $stor eq "WebGUI::Storage" and $stor->delete;
}
- if ($savecdn) {
- $session->config->set('cdn', $savecdn);
- } else {
- $session->config->delete('cdn');
- }
- $addedCdnQ and rmdir $addedCdnQ;
- $addedCdnU and rmdir $addedCdnU;
}
diff --git a/t/templateSyntax.t b/t/templateSyntax.t
new file mode 100644
index 000000000..b64437b63
--- /dev/null
+++ b/t/templateSyntax.t
@@ -0,0 +1,48 @@
+#-------------------------------------------------------------------
+# 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 warnings;
+use lib "$FindBin::Bin/lib"; ##t/lib
+
+use WebGUI::Test;
+use WebGUI::Session;
+use Data::Dumper;
+use WebGUI::Asset::Template;
+
+#The goal of this test is to locate poorly used macros in the default
+#templates;
+
+use Test::More; # increment this value for each test you create
+my $numTests = 0;
+
+my $session = WebGUI::Test->session;
+my $lib = WebGUI::Test->lib;
+
+# put your tests here
+
+$numTests = $session->db->quickScalar('select count(distinct(assetId)) from template');
+
+plan tests => $numTests;
+
+my $getATemplate = WebGUI::Asset::Template->getIsa($session);
+
+while (my $templateAsset = $getATemplate->()) {
+ my $output = $templateAsset->process({});
+ unlike(
+ $output,
+ qr/\AError processing template:/,
+ sprintf "%s: %s (%s) has no syntax errors",
+ $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl
+ );
+}
+
+