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;
}