Merge up to 10305

This commit is contained in:
Colin Kuskie 2009-04-13 17:04:23 +00:00
parent fa2e5c2c90
commit 1edaca4ed2
65 changed files with 1300 additions and 477 deletions

View file

@ -63,12 +63,14 @@ $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');
WebGUI::Test->groupsToDelete($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');
WebGUI::Test->groupsToDelete($testGroups{'canAdd asset'});
my $canAddMaker = WebGUI::Test::Maker::Permission->new();
$canAddMaker->prepare({
@ -819,9 +821,6 @@ END {
foreach my $user (values %testUsers) {
$user->delete;
}
foreach my $group (values %testUsers) {
$group->delete;
}
}
##Return an array of hashrefs. Each hashref describes a test

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use WebGUI::User;
use WebGUI::Asset;
use Test::More tests => 92; # increment this value for each test you create
use Test::More tests => 90; # increment this value for each test you create
use Test::Deep;
# Test the methods in WebGUI::AssetLineage
@ -195,12 +195,10 @@ is(
#
####################################################
ok(!$snippet2->setParent($folder), 'setParent: user must be in group 4 to do this');
$session->user({userId => $editor->userId});
ok(!$snippet2->setParent(), 'setParent: new parent must be passed in');
ok(!$snippet2->setParent($snippet2), 'setParent: cannot be your own parent');
ok(!$snippet2->setParent($folder2), 'setParent: will not move self to current parent');
ok(!$snippet2->setParent($folder), 'setParent: user cannot edit parent');
$session->user({userId => 3});
ok(!$folder2->setParent($snippet2), 'setParent: will not move self to my child');

View file

@ -60,6 +60,7 @@ my $otherUser = WebGUI::User->new($session, 'new');
my $groupIdEditUser = WebGUI::User->new($session, 'new');
my $groupToEditPost = WebGUI::Group->new($session, $collab->get('groupToEditPost'));
my $groupIdEditGroup = WebGUI::Group->new($session, $collab->get('groupIdEdit'));
WebGUI::Test->groupsToDelete($groupToEditPost, $groupIdEditGroup);
$postingUser->username('userForPosting');
$otherUser->username('otherUser');

View file

@ -0,0 +1,49 @@
#-------------------------------------------------------------------
# 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";
##The goal of this test is to test the creation of Carousel Wobjects.
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 2; # increment this value for each test you create
use WebGUI::Asset::Wobject::Carousel;
my $session = WebGUI::Test->session;
# Do our work in the import node
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Search Test"});
my $carousel = $node->addChild({className=>'WebGUI::Asset::Wobject::Carousel'});
# Test for a sane object type
isa_ok($carousel, 'WebGUI::Asset::Wobject::Carousel');
# Test to see if we can set new values
my $newSettings = {
templateId=>'testingtestingtesting1',
};
$carousel->update($newSettings);
foreach my $newSetting (keys %{$newSettings}) {
is ($carousel->get($newSetting), $newSettings->{$newSetting}, "updated $newSetting is ".$newSettings->{$newSetting});
}
END {
# Clean up after thy self
$versionTag->rollback();
}

View file

@ -32,7 +32,7 @@ use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Wobject::Layout;
use Data::Dumper;
use Test::More tests => 7; # increment this value for each test you create
use Test::More tests => 10; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -50,7 +50,10 @@ my $layout = $node->addChild({className => 'WebGUI::Asset::Wobject::Layout'});
$session->asset($layout);
# finally, add the collab
my $collab = $layout->addChild({className => 'WebGUI::Asset::Wobject::Collaboration'});
my $collab = $layout->addChild({
className => 'WebGUI::Asset::Wobject::Collaboration',
url => 'collab',
});
# Test for a sane object type
isa_ok($collab, 'WebGUI::Asset::Wobject::Collaboration');
@ -91,6 +94,11 @@ $post = $collab->addChild($props,
my $rssitems = $collab->getRssFeedItems();
is(scalar @{ $rssitems }, 2, 'rssitems set to number of posts added');
diag "AssetAspect tests";
is($collab->getRssFeedUrl, '/collab?func=viewRss', 'getRssFeedUrl');
is($collab->getRdfFeedUrl, '/collab?func=viewRdf', 'getRdfFeedUrl');
is($collab->getAtomFeedUrl, '/collab?func=viewAtom', 'getAtomFeedUrl');
TODO: {
local $TODO = "Tests to make later";
ok(0, 'A whole lot more work to do here');

View file

@ -22,23 +22,24 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 36;
my $tests = 41;
plan tests => $tests + 1;
#----------------------------------------------------------------------------
# put your tests here
my $usedOk = use_ok('WebGUI::Asset::Wobject::Survey::ExpressionEngine');
my ($user, $survey, $versionTag);
SKIP: {
skip $tests, "Unable to load ExpressionEngine" unless $usedOk;
my $e = "WebGUI::Asset::Wobject::Survey::ExpressionEngine";
WebGUI::Test->originalConfig('enableSurveyExpressionEngine');
$session->config->set( 'enableSurveyExpressionEngine', 0 );
is( $e->run( $session, 'jump { 1 } target' ),
undef, "Nothing happens unless we turn on enableSurveyExpressionEngine in config" );
WebGUI::Test->originalConfig('enableSurveyExpressionEngine');
$session->config->set( 'enableSurveyExpressionEngine', 1 );
is( $e->run( $session, 'jump { 1 } target' ), 'target', "..now we're in business!" );
@ -109,8 +110,63 @@ SKIP: {
undef, 'target is not valid' );
is( $e->run( $session, q{jump {1} target}, { values => \%values, validTargets => { target => 1 } } ),
'target', '..whereas now it is ok' );
# Create a test user
$user = WebGUI::User->new( $session, 'new' );
# Create a Survey
$versionTag = WebGUI::VersionTag->getWorking($session);
$survey = WebGUI::Asset->getImportNode($session)->addChild(
{ className => 'WebGUI::Asset::Wobject::Survey',
},
);
isa_ok($survey, 'WebGUI::Asset::Wobject::Survey');
my $url = $survey->get('url');
my $id = $survey->getId;
$survey->surveyJSON->newObject([]); # s0
$survey->surveyJSON->newObject([0]); # s0q0
$survey->surveyJSON->newObject([0,0]); # s0q0a0
$survey->surveyJSON->newObject([0]); # s0q1
$survey->surveyJSON->newObject([0,1]); # s0q1a0
$survey->surveyJSON->section([0])->{variable} = 'ext_s0';
$survey->surveyJSON->question([0,0])->{variable} = 'ext_s0q0';
$survey->surveyJSON->question([0,1])->{variable} = 'ext_s0q1';
$survey->surveyJSON->answer([0,0,0])->{recordedAnswer} = 'ext_s0q0a0';
$survey->surveyJSON->answer([0,0,0])->{value} = 150; # worth 150 points
$survey->surveyJSON->answer([0,1,0])->{recordedAnswer} = 'ext_s0q1a0';
$survey->surveyJSON->answer([0,1,0])->{value} = 50; # worth 50 points
$survey->responseIdCookies(0); # disable cookies so that test code doesn't die
my $responseId = $survey->responseId($user->userId);
my $rJSON = $survey->responseJSON(undef, $responseId);
$rJSON->recordResponses({
'0-0-0' => 'My ext_s0q0a0 answer',
'0-1-0' => 'My ext_s0q1a0 answer',
});
# Remember to persist our changes..
$survey->persistSurveyJSON();
$survey->persistResponseJSON();
$survey->surveyEnd;
is( $e->run( $session, qq{jump {value('$id', ext_s0q0) eq 'ext_s0q0a0'} target}, {userId => $user->userId} ),
'target', 'external value resolves ok when id used' );
is( $e->run( $session, qq{jump {value('$url', ext_s0q0) eq 'ext_s0q0a0'} target}, {userId => $user->userId} ),
'target', 'external value resolves ok when url used' );
is( $e->run( $session, qq{jump {score('$url', ext_s0q0) == 150} target}, {userId => $user->userId} ),
'target', 'external score resolves ok too' );
is( $e->run( $session, qq{jump {score('$url', ext_s0) == 200} target}, {userId => $user->userId} ),
'target', 'external score section totals work too' );
}
#----------------------------------------------------------------------------
# Cleanup
END { }
END {
$user->delete if $user;
$survey->purge if $survey;
$versionTag->rollback if $versionTag;
}

View file

@ -233,6 +233,7 @@ my $gB = WebGUI::Group->new($session, "new");
$gA->name('Group A');
$gB->name('Group B');
ok( ($gA->name eq 'Group A' and $gB->name eq 'Group B'), 'object name assignment, multiple objects');
WebGUI::Test->groupsToDelete($gA, $gB);
$gB->addGroups([$gA->getId]);
@ -253,6 +254,7 @@ cmp_bag($gA->getGroupsIn(), [3], 'Not allowed to add myself to my group');
my $gC = WebGUI::Group->new($session, "new");
$gC->name('Group C');
$gA->addGroups([$gC->getId]);
WebGUI::Test->groupsToDelete($gC);
cmp_bag($gC->getGroupsFor(), [$gA->getId], 'Group A contains Group C');
cmp_bag($gA->getGroupsIn(), [$gC->getId, 3], 'Group C is a member of Group A, cached');
@ -279,6 +281,7 @@ my $gZ = WebGUI::Group->new($session, "new");
$gX->name('Group X');
$gY->name('Group Y');
$gZ->name('Group Z');
WebGUI::Test->groupsToDelete($gX, $gY, $gZ);
$gZ->addGroups([$gX->getId, $gY->getId]);
@ -439,6 +442,7 @@ ok( isIn($mob[0]->userId, @{ $gZ->getAllUsers() }), 'mob[0] in list of group Z u
my $gK = WebGUI::Group->new($session, "new");
$gK->name('Group K');
$gC->addGroups([$gK->getId]);
WebGUI::Test->groupsToDelete($gK);
# B
# / \
@ -498,6 +502,7 @@ $session->setting->set('useKarma', $defaultKarmaSetting);
my $gS = WebGUI::Group->new($session, "new");
$gS->name('Group S');
$gC->addGroups([$gS->getId]);
WebGUI::Test->groupsToDelete($gS);
# B
# / \
@ -579,6 +584,7 @@ foreach my $idx (0..$#ipTests) {
}
my $gI = WebGUI::Group->new($session, "new");
WebGUI::Test->groupsToDelete($gI);
$gI->name('Group I');
$gI->ipFilter('194.168.0.0/24');
@ -614,6 +620,7 @@ ok( !$cacheDude->isInGroup($gY->getId), "Cache dude removed from group Y");
ok( !$cacheDude->isInGroup($gZ->getId), "Cache dude removed from group Z too");
my $gCache = WebGUI::Group->new($session, "new");
WebGUI::Test->groupsToDelete($gCache);
$gCache->addUsers([$cacheDude->userId]);
@ -642,10 +649,13 @@ SKIP: {
ok(undef, "expiration date in groupings for getUser");
}
################################################################
#
# getUserList
#
################################################################
END {
foreach my $testGroup ($gX, $gY, $gZ, $gA, $gB, $gI, $gC, $g, $gK, $gS, $gCache) {
$testGroup->delete if (defined $testGroup and ref $testGroup eq 'WebGUI::Group');
}
foreach my $dude ($user, @crowd, @mob, @chameleons, @itchies, @tcps, $cacheDude) {
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
}

View file

@ -53,12 +53,6 @@ my @testArray = (
output => 0,
comment => "s.also Privoxy/3.0 (Anonymous)"
},
{
agent => "*/Nutch-0.9-dev",
address => "123.113.184.232",
output => 1,
comment => "Unknown Yahoo robot"
},
{
agent => "123spider-Bot (Version: 1.02, powered by www.123spider.de",
output => 1,

View file

@ -51,6 +51,8 @@ our $logger_error;
my %originalConfig;
my $originalSetting;
my @groupsToDelete;
BEGIN {
STDERR->autoflush(1);
@ -129,12 +131,15 @@ BEGIN {
$SESSION = WebGUI::Session->open( $WEBGUI_ROOT, $CONFIG_FILE );
$SESSION->{_request} = $pseudoRequest;
$originalSetting = clone $SESSION->setting;
$originalSetting = clone $SESSION->setting->get;
}
END {
my $Test = Test::Builder->new;
foreach my $group (@groupsToDelete) {
$group->delete;
}
if ($ENV{WEBGUI_TEST_DEBUG}) {
$Test->diag('Sessions: '.$SESSION->db->quickScalar('select count(*) from userSession'));
$Test->diag('Scratch : '.$SESSION->db->quickScalar('select count(*) from userSessionScratch'));
@ -149,8 +154,7 @@ END {
$SESSION->config->delete($key);
}
}
my $settings = $originalSetting->get();
while (my ($param, $value) = each %{ $settings }) {
while (my ($param, $value) = each %{ $originalSetting }) {
$SESSION->setting->set($param, $value);
}
$SESSION->var->end;
@ -384,6 +388,20 @@ sub originalConfig {
#----------------------------------------------------------------------------
=head2 groupsToDelete ( $group, [$group ] )
Push a list of group objects onto the stack of groups to be automatically deleted
at the end of the test.
=cut
sub groupsToDelete {
my $class = shift;
push @groupsToDelete, @_;
}
#----------------------------------------------------------------------------
=head1 BUGS
When trying to load the APR module, perl invariably throws an Out Of Memory