Merge commit '63865eb39f' into WebGUI8. up to 7.9.11

This commit is contained in:
Colin Kuskie 2010-08-13 11:52:08 -07:00
commit 7b218942b3
72 changed files with 3085 additions and 407 deletions

View file

@ -21,10 +21,11 @@ use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset::File;
use JSON;
use Test::More; # increment this value for each test you create
use Test::Deep;
plan tests => 10;
plan tests => 13;
#TODO: This script tests certain aspects of WebGUI::Storage and it should not
@ -47,7 +48,7 @@ cmp_bag($storage->getFiles, ['someScalarFile.txt'], 'Only 1 file in storage with
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"File Asset test"});
my $guard1 = cleanupGuard($versionTag);
my $guard1 = WebGUI::Test::addToCleanup($versionTag);
my $properties = {
# '1234567890123456789012'
id => 'FileAssetTest000000012',
@ -85,12 +86,47 @@ $versionTag->commit;
############################################
my $fileStorage = WebGUI::Storage->create($session);
my $guard2 = cleanupGuard($fileStorage);
$mocker->set_always('get', $fileStorage->getId);
WebGUI::Test->addToCleanup($fileStorage);
$mocker->set_always('get', $fileStorage->getId);
$mocker->set_always('getValue', $fileStorage->getId);
my $fileFormStorage = $asset->getStorageFromPost();
isa_ok($fileFormStorage, 'WebGUI::Storage', 'Asset::File::getStorageFromPost');
#----------------------------------------------------------------------------
# Test override of update to set permissions
$asset->update({ ownerUserId => '3', groupIdView => '3' });
my $privs = JSON->new->decode( $asset->getStorageLocation->getFileContentsAsScalar('.wgaccess') );
cmp_deeply(
$privs,
{
"assets" => [],
"groups" => superbagof( "3" ),
"users" => ["3"],
},
'update sets the correct permissions in wgaccess',
);
#----------------------------------------------------------------------------
# Add another new revision, changing the privs
my $newRev = $asset->addRevision( { ownerUserId => '3', groupIdView => '3' }, time + 5 );
WebGUI::Test::addToCleanup( WebGUI::VersionTag->getWorking( $session ) );
$privs = JSON->new->decode( $newRev->getStorageLocation->getFileContentsAsScalar('.wgaccess') );
cmp_deeply(
$privs,
{
"assets" => [],
"groups" => superbagof( "3" ),
"users" => ["3"],
},
'addRevision sets the correct permissions in wgaccess',
);
# Add a new revision, changing the privs
my $newRev = $asset->addRevision( { groupIdView => '7' }, time + 8 );
WebGUI::Test::addToCleanup( WebGUI::VersionTag->getWorking( $session ) );
is( $newRev->getStorageLocation->getFileContentsAsScalar('.wgaccess'), undef, "wgaccess doesn't exist" );
note( @{ $newRev->getStorageLocation->getFiles() } );
############################################
#
# www_view

View file

@ -52,8 +52,8 @@ $file->setFile( WebGUI::Test->getTestCollateralPath("International/lib/WebGUI/i1
my $storage = $file->getStorageLocation;
is_deeply(
$storage->getFiles, ['WebGUI.pm'],
"Storage location contains only the file we added",
$storage->getFiles, ['WebGUI_pm.txt'],
"Storage location contains only the file we added, name was changed to prevent uploading of code",
);
#vim:ft=perl

View file

@ -0,0 +1,127 @@
# 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
#------------------------------------------------------------------
# This tests the AssetReport asset
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
use Test::More;
use Test::Deep;
use JSON;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode( $session );
#----------------------------------------------------------------------------
# Tests
plan tests => 3; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Asset Report creation
use_ok( "WebGUI::Asset::Wobject::AssetReport" );
my $ar = $node->addChild( {
className => 'WebGUI::Asset::Wobject::AssetReport',
} );
isa_ok( $ar, 'WebGUI::Asset::Wobject::AssetReport' );
WebGUI::Test->addToCleanup($ar);
my $f = $node->addChild({
className => 'WebGUI::Asset::Wobject::Folder',
title => 'Asset Report Test',
});
WebGUI::Test->addToCleanup($f);
my $sn = $f->addChild({
className => 'WebGUI::Asset::Snippet',
title => 'Shawshank',
});
#----------------------------------------------------------------------------
# Value and variables
my $value = {
isNew => "false",
className => "WebGUI::Asset::Snippet",
startNode => $f->getId,
anySelect => "or",
where => {
1 => {
opSelect => "=",
propSelect => "assetData.title",
valText => "Shawshank"
},
},
whereCount => "2",
order => {
1 => {
dirSelect => "desc",
orderSelect => "assetData.title"
},
},
orderCount => "2",
limit => "0",
};
my $settings = JSON->new->encode( $value );
$ar->update( {
settings => $settings,
paginateAfter => 50,
} );
#----------------------------------------------------------------------------
# getTemplateVars
cmp_deeply(
$ar->getTemplateVars,
hash( {
%{ $ar->get },
'settings' => $settings,
'paginateAfter' => 50,
'templateId' => 'sJtcUCfn0CVbKdb4QM61Yw',
'pagination.firstPageUrl' => ignore(),
'pagination.isLastPage' => ignore(),
'pagination.nextPage' => ignore(),
'pagination.previousPageUrl' => ignore(),
'pagination.lastPageText' => ignore(),
'pagination.pageCount' => ignore(),
'pagination.firstPageText' => ignore(),
'pagination.previousPage' => ignore(),
'pagination.pageLoop' => ignore(),
'pagination.lastPage' => ignore(),
'pagination.lastPageUrl' => ignore(),
'pagination.pageNumber' => ignore(),
'pagination.pageList.upTo10' => ignore(),
'pagination.pageCount.isMultiple' => ignore(),
'pagination.pageList' => ignore(),
'pagination.previousPageText' => ignore(),
'pagination.nextPageUrl' => ignore(),
'pagination.pageLoop.upTo10' => ignore(),
'pagination.pageList.upTo20' => ignore(),
'pagination.pageLoop.upTo20' => ignore(),
'pagination.isFirstPage' => ignore(),
'pagination.nextPageText' => ignore(),
'pagination.firstPage' => ignore(),
'asset_loop' => [{ %{ $sn->get } }],
} ),
"getTemplateVars returns complete and correct data structure",
);
#vim:ft=perl

View file

@ -181,8 +181,6 @@ my $json = $matrix->www_getCompareFormData('score');
my $compareFormData = JSON->new->decode($json);
$expectedAssetId =~ s/-/_____/g;
cmp_deeply(
$compareFormData,
{ResultSet=>{

View file

@ -106,7 +106,6 @@ my $uploadsPath = Path::Class::Dir->new($session->config->get('uploadsPath'));
my $uploadsUrl = Path::Class::Dir->new($session->config->get('uploadsURL'));
my $graphRelative = $graphUrl->relative($uploadsUrl);
my $graphFile = $uploadsPath->file($graphRelative);
note $graphFile->stringify;
ok(-e $graphFile->stringify, 'graph exists');

View file

@ -31,7 +31,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 18;
plan tests => 20;
#----------------------------------------------------------------------------
# put your tests here
@ -55,6 +55,7 @@ WebGUI::Test->addToCleanup($versionTag);
my $pastStory = $newFolder->addChild({ className => 'WebGUI::Asset::Story', title => "Yesterday is history", keywords => 'andy,norton'});
$creationDateSth->execute([$yesterday, $pastStory->getId]);
$pastStory->requestAutoCommit;
$pastStory = $pastStory->cloneFromDb;
my @staff = qw/norton hadley mert trout/;
my @inmates = qw/bogs red brooks andy heywood tommy jake skeet/;
@ -321,3 +322,61 @@ cmp_deeply(
],
'rssFeedItems'
);
################################################################
# Sort Order
################################################################
$pastStory->update( { title => "aaaay was history but isn't any more" } );
$pastStory->requestAutoCommit;
$pastStory = $pastStory->cloneFromDb;
$topic->update({ storiesPer => 4, storiesShort => 4, }); # storiesPer is used when _standAlone is true, storiesShort otherwise
$topic->{_standAlone} = 0;
$topic->update( { storySortOrder => 'Alphabetically' } );
$templateVars = $topic->viewTemplateVariables();
cmp_deeply(
$templateVars->{story_loop},
[
{
title => "aaaay was history but isn't any more",
url => ignore(),
creationDate => $yesterday,
},
{
title => 'andy',
url => ignore(),
creationDate => $now,
},
{
title => 'bogs',
url => ignore(),
creationDate => $now,
},
{
title => 'brooks',
url => ignore(),
creationDate => $now,
},
],
'viewTemplateVars has right number and contents in the story_loop in sort order Alphabetically mode'
);
################################################################
# Regression -- Empty StoryTopics shouldn't blow up
################################################################
my $emptyarchive = WebGUI::Asset->getDefault($session)->addChild({
className => 'WebGUI::Asset::Wobject::StoryTopic',
title => 'Why Do Good Things Happen To Bad People',
url => '/home/badstories',
keywords => 'aksjhgkja asgjhshs assajshhsg5',
});
WebGUI::Test->addToCleanup($emptyarchive); # blows up under the debugger...?
$versionTag->commit;
$emptyarchive->{_standAlone} = 1;
ok(eval { $emptyarchive->viewTemplateVariables() }, "viewTemplateVariables with _standAlone = 1 doesn't throw an error");

View file

@ -155,30 +155,30 @@ my $tag_set2 = WebGUI::VersionTag->getWorking($session);
$tag_set2->commit;
WebGUI::Test->addToCleanup($tag_set2);
cmp_bag(
cmp_deeply(
$wiki->getKeywordHierarchy(),
[
{
title => 'criminals', url => '/testwiki?func=byKeyword;keyword=criminals',
children => bag(
superhashof({ title => 'red', }),
children => set(
superhashof({ title => 'andy', }),
superhashof({ title => 'red', }),
),
descendants => 0,
},
{
title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates',
children => bag(
superhashof({ title => 'heywood', }),
children => set(
superhashof({ title => 'brooks', }),
superhashof({ title => 'heywood', }),
),
descendants => 0,
},
{
title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff',
children => bag(
superhashof({ title => 'norton', }),
children => set(
superhashof({ title => 'hadley', }),
superhashof({ title => 'norton', }),
),
descendants => 0,
},
@ -194,22 +194,22 @@ my $tag_set3 = WebGUI::VersionTag->getWorking($session);
$tag_set3->commit;
WebGUI::Test->addToCleanup($tag_set3);
cmp_bag(
cmp_deeply(
$wiki->getKeywordHierarchy(),
[
superhashof({
title => 'criminals',
children => bag(
children => set(
superhashof({
title => 'andy',
children => bag(
children => set(
superhashof({
title => 'inmates',
children => bag(
children => set(
superhashof({ title => 'heywood', }),
superhashof({
title => 'brooks',
children => bag(
children => set(
superhashof({ title => 'criminals', }),
),
}),
@ -226,7 +226,7 @@ cmp_bag(
}),
superhashof({
title => 'staff',
children => bag(
children => set(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }),
),

157
t/Asset/dispatch.t Normal file
View file

@ -0,0 +1,157 @@
# 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 asset dispatch system
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
BEGIN {
$INC{'WebGUI/Asset/TestDispatch.pm'} = __FILE__;
}
package WebGUI::Asset::TestDispatch;
use WebGUI::Asset;
use WebGUI::Exception;
our @ISA = ('WebGUI::Asset');
# Override dispatch to handle special /foo URL
sub dispatch {
my ( $self, $fragment ) = @_;
if ( $fragment eq '/foo' ) {
return "bar";
}
return $self->SUPER::dispatch( $fragment );
}
sub www_view {
return "www_view";
}
sub www_edit {
return "www_edit";
}
sub www_alsoView {
return;
}
sub www_brokenTemplate {
my $self = shift;
WebGUI::Error::ObjectNotFound::Template->throw(
error => qq{Template not found},
templateId => "This is a GUID",
assetId => $self->getId,
);
}
sub www_dies {
my $self = shift;
die "...aside from that bullet\n";
}
package main;
my $tag = WebGUI::VersionTag->getWorking( $session );
WebGUI::Test->addToCleanup( $tag );
#----------------------------------------------------------------------------
# Tests
plan tests => 18; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Test dispatch
# Add a TestDispatch asset and test
my $td = WebGUI::Asset->getImportNode( $session )->addChild( {
url => 'testDispatch',
className => 'WebGUI::Asset::TestDispatch',
} );
is( $td->dispatch, "www_view", "dispatch with no fragment shows www_view" );
is( $td->dispatch( '/foo' ), 'bar', 'dispatch detects fragment and returns' );
ok( !$td->dispatch( '/unhandled' ), 'dispatch with unknown fragment returns false' );
# Test func=
$session->request->setup_body( {
func => 'edit',
} );
is( $td->dispatch, "www_edit", "dispatch handles ?func= query param" );
is( $td->dispatch( '/foo' ), "bar", "overridden dispatch trumps ?func= query param" );
# Test func= can only be run on the exact asset we requested
my $output = $td->dispatch( '/bar' );
is( $output, undef, "dispatch returned undef, meaning that it declined to handle the request for a func but the wrong URL" );
isnt( $output, "www_edit", "?func= dispatch cancelled because of unhandled fragment" );
# Test unhandled options
$session->request->setup_body( {
func => 'notAMethod',
} );
is( $td->dispatch, "www_view", "requests for non-existant methods return www_view method" );
# Test unhandled options
$session->request->setup_body( {
func => 'alsoView',
} );
is( $td->dispatch, "www_view", "if a query method returns undef, view is still returned" );
$session->request->setup_body( { } );
$output = $td->dispatch( '/not-foo' );
is( $output, undef, "dispatch returned undef, meaning that it declined to handle the request for the wrong URL" );
isnt( $output, "www_view", "?func= dispatch cancelled because of unhandled fragment" );
$td->cut();
$output = $td->dispatch();
is $output, undef, 'dispatch returns undef when trying to access an asset that is not published, and admin is not on';
$session->var->switchAdminOn;
$output = $td->dispatch();
is $output, 'www_view', 'when admin is on, the asset can be accessed';
$td->publish();
$session->var->switchAdminOff;
$output = $td->dispatch();
is $output, 'www_view', 'asset state restored for next tests';
# Test template exceptions
$session->request->setup_body( {
func => 'brokenTemplate',
} );
WebGUI::Test->interceptLogging(sub {
my $log_data = shift;
is( $td->dispatch, "www_view", "if a query method throws a Template exception, view is returned instead" );
is $log_data->{error}, 'Template not found templateId: This is a GUID assetId: '. $td->getId, '... and logged an error';
});
WebGUI::Test->interceptLogging(sub {
my $log_data = shift;
$session->request->setup_body( {
func => 'dies',
} );
is( $td->dispatch, "www_view", "if a query method dies, view is returned instead" );
is $log_data->{warn}, "Couldn't call method www_dies on asset for url: Root cause: ...aside from that bullet\n", '.. and logged a warn';
});
#vim:ft=perl

177
t/Content/Asset.t Normal file
View file

@ -0,0 +1,177 @@
# 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
#------------------------------------------------------------------
# Write a little about what this script tests.
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Content::Asset;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
BEGIN {
$INC{'WebGUI/Asset/TestDispatch.pm'} = __FILE__;
$INC{'WebGUI/Asset/TestDecline.pm'} = __FILE__;
}
package WebGUI::Asset::TestDispatch;
our @ISA = ('WebGUI::Asset');
# Override dispatch to handle special /foo URL
sub dispatch {
my ( $self, $fragment ) = @_;
if ( $fragment eq '/foo' ) {
return "bar";
}
return $self->SUPER::dispatch( $fragment );
}
sub www_edit {
my ( $self ) = @_;
return "www_edit " . $self->get('title');
}
sub www_view {
my ( $self ) = @_;
return "www_view " . $self->get('title');
}
package WebGUI::Asset::TestDecline;
our @ISA = ( 'WebGUI::Asset' );
# Override dispatch to decline everything
sub dispatch { return; }
sub www_edit { return "you'll never see me!" }
package main;
my $td
= WebGUI::Asset->getImportNode( $session )->addChild( {
title => "one",
className => 'WebGUI::Asset::TestDispatch',
url => 'testdispatch',
} );
WebGUI::Test->addToCleanup( WebGUI::VersionTag->getWorking( $session ) );
#----------------------------------------------------------------------------
# Tests
plan tests => 15; # Increment this number for each test you create
#----------------------------------------------------------------------------
# test getUrlPermutation( url ) method
cmp_deeply(
WebGUI::Content::Asset::getUrlPermutations( ),
[ ],
"Handles no URL gracefully",
);
cmp_deeply(
WebGUI::Content::Asset::getUrlPermutations( "one" ),
[ 'one' ],
"simple one element URL",
);
cmp_deeply(
WebGUI::Content::Asset::getUrlPermutations( "/one" ),
[ '/one', ],
"simple one element URL with leading slash",
);
cmp_deeply(
WebGUI::Content::Asset::getUrlPermutations( "one/two/three" ),
[ 'one/two/three', 'one/two', 'one', ],
"three element URL",
);
cmp_deeply(
WebGUI::Content::Asset::getUrlPermutations( "/one/two/three" ),
[ '/one/two/three', '/one/two', '/one', ],
"three element URL with leading slash",
);
cmp_deeply(
WebGUI::Content::Asset::getUrlPermutations( "/one/two/three.rss" ),
[ '/one/two/three.rss', '/one/two/three', '/one/two', '/one', ],
".ext is a seperate URL permutation",
);
#----------------------------------------------------------------------------
# test dispatch( session, url ) method
is ($session->asset, undef, 'session asset is not defined, yet');
is(
WebGUI::Content::Asset::dispatch( $session, "testdispatch" ),
"www_view one",
"Regular www_view",
);
is ($session->asset->getId, $td->getId, 'dispatch set the session asset');
is(
WebGUI::Content::Asset::dispatch( $session, "testdispatch/foo" ),
"bar",
"special /foo handler",
);
# Add an asset that clobbers the TestDispatch's /foo
my $clobberingTime
= WebGUI::Asset->getImportNode( $session )->addChild( {
title => "two",
className => 'WebGUI::Asset::TestDispatch',
url => $td->get('url') . '/foo',
} );
WebGUI::Test->addToCleanup($clobberingTime);
is(
WebGUI::Content::Asset::dispatch( $session, "testdispatch/foo" ),
"www_view two",
"dispatch to the asset with the longest URL",
);
is ($session->asset->getId, $clobberingTime->getId, 'dispatch reset the session asset');
$clobberingTime->purge;
# Add an asset that declines everything instead
my $declined
= WebGUI::Asset->getImportNode( $session )->addChild( {
title => "three",
className => 'WebGUI::Asset::TestDecline',
url => $td->get('url') . '/foo',
} );
is(
WebGUI::Content::Asset::dispatch( $session, "testdispatch/foo" ),
"bar",
"Dispatch passes to TestDispatch asset after declined",
);
# Test ?func= dispatch with declined asset
$session->request->setup_body({
func => "edit",
});
my $output = WebGUI::Content::Asset::dispatch( $session, "testdispatch/foo" );
isnt( $output, "you'll never see me!", "func=edit was declined" );
isnt( $output, "www_edit one", "func=edit was not for us" );
#vim:ft=perl

View file

@ -77,5 +77,5 @@ $xmlData = XMLin($output,
cmp_deeply(
\@actual_urls,
\@expected_urls,
'hidden pages hidden'
'hidden pages shown'
);

View file

@ -26,7 +26,7 @@ my $session = WebGUI::Test->session;
# put your tests here
plan tests => 28;
plan tests => 30;
my $timeZoneUser = addUser($session);
@ -91,6 +91,16 @@ ok($@, 'new croaks on an out of range time');
my $badday = eval { WebGUI::DateTime->new($session, '2001-08-16 99:199:99'); };
ok($@, 'new croaks on an illegal time');
#----------------------------------------------------------------------------
# Test webguiToStrftime conversion
is( $nowDt->webguiToStrftime('%y-%m-%d'), '%Y-%m-%d', 'webgui to strftime conversion' );
$timeZoneUser->update({ 'dateFormat' => '%y-%M-%D' });
$timeZoneUser->update({ 'timeFormat' => '%H:%n %p' });
is( $nowDt->webguiToStrftime, '%Y-%_varmonth_-%e %l:%M %P', 'default datetime string' );
sub addUser {
my $session = shift;
my $user = WebGUI::User->new($session, "new");

59
t/Form/AssetReportQuery.t Normal file
View file

@ -0,0 +1,59 @@
#-------------------------------------------------------------------
# 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::Form;
use WebGUI::Form::AssetReportQuery;
use WebGUI::Session;
use HTML::Form;
use WebGUI::Form_Checking;
#The goal of this test is to verify that Radio form elements work
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode( $session );
my $nodeId = $node->getId;
#----------------------------------------------------------------------------
# Tests
plan tests => 1; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
$session->request->setup_body({
className => "WebGUI::Asset",
propCount => 2,
orderCount => 2,
startNode => $nodeId,
startNode_display => "Import Node",
anySelect => "or",
propSelect_1 => "asset.createdBy",
opSelect_1 => "=",
valText_1 => "3",
orderSelect_1 => "assetData.title",
dirSelect_1 => "desc",
limit => "25",
});
my $arq = WebGUI::Form::AssetReportQuery->new($session);
my $expected = qq|{"anySelect":"or","className":"WebGUI::Asset","isNew":"false","limit":"25","order":{"1":{"dirSelect":"desc","orderSelect":"assetData.title"}},"orderCount":2,"startNode":"$nodeId","where":{"1":{"opSelect":"=","propSelect":"asset.createdBy","valText":"3"}},"whereCount":2}|;
is($arq->getValue, $expected, 'getValue');
#my $value = $session->form->process("settings","AssetReportQuery");

View file

@ -287,7 +287,6 @@ cmp_bag($gB->getGroupsIn(), [$gA->getId, 3], 'Group A is in Group B');
cmp_bag($gA->getGroupsFor(), [$gB->getId], 'Group B contains Group A');
cmp_bag($gA->getGroupsIn(), [3], 'Admin added to group A automatically');
diag $gA->getId;
$gA->addGroups([$gB->getId]);
cmp_bag($gA->getGroupsIn(), [3], 'Not allowed to create recursive group loops');

View file

@ -130,8 +130,6 @@ is(scalar @{ $inbox->getMessagesForUser($admin, '', '', '', 'sentBy='.$session->
is($inbox->getUnreadMessageCount($admin->userId), 4, 'getUnreadMessageCount');
my $messages = $inbox->getMessagesForUser($admin);
$messages->[0]->setRead($admin->userId);
note $messages->[0]->getStatus;
note $messages->[0]->isRead;
is($inbox->getUnreadMessageCount($admin->userId), 3, '... really tracks unread messages');
#vim:ft=perl

View file

@ -17,7 +17,7 @@ use WebGUI::Keyword;
use WebGUI::Asset;
# load your modules here
use Test::More tests => 15; # increment this value for each test you create
use Test::More tests => 16; # increment this value for each test you create
use Test::Deep;
use Data::Dumper;
@ -76,10 +76,28 @@ my $assetIds = $keyword->getMatchingAssets({ keyword => 'webgui', });
cmp_deeply(
$assetIds,
[$snippet->getId, $home->getId, ],
[ $snippet->getId, $home->getId, ],
'getMatchingAssets, by keyword, assetIds in order by creationDate, descending'
);
# sorted by title, alphabetically
my $aa_story = $home->addChild({ className => 'WebGUI::Asset::Snippet', title => "aaaa", keywords => 'webgui' });
WebGUI::Test->addToCleanup($aa_story);
$assetIds = $keyword->getMatchingAssets({ keyword => 'webgui', sortOrder => 'Alphabetically', });
cmp_deeply(
$assetIds,
[ $aa_story->getId, $snippet->getId, $home->getId, ], # 'aaa', 'Home', 'keyword snippet'
'getMatchingAssets, by keyword, assetIds in order by title'
);
$aa_story->trash();
$aa_story->purge();
# trashed assets
$snippet->trash();
cmp_deeply(

View file

@ -31,6 +31,7 @@ use Test::Deep::Shallow;
use Test::Deep::Blessed;
use Test::Deep::Isa;
use Test::Deep::Set;
use Test::Exception;
use WebGUI::Pluggable;
@ -41,7 +42,7 @@ use WebGUI::Pluggable;
#----------------------------------------------------------------------------
# Tests
plan tests => 12; # Increment this number for each test you create
plan tests => 19; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -62,6 +63,15 @@ is($dumper->Dump, q|$VAR1 = {
};
|, "Can instanciate an object.");
dies_ok { WebGUI::Pluggable::load( '::HA::HA' ) } 'load dies on bad input';
like( $@, qr/^\QInvalid module name: ::HA::HA/, 'helpful error message' );
dies_ok { WebGUI::Pluggable::load( 'HA::HA::' ) } 'load dies on bad input';
dies_ok { WebGUI::Pluggable::load( 'HA::..::..::HA' ) } 'load dies on bad input';
dies_ok { WebGUI::Pluggable::load( '..::..::..::HA' ) } 'load dies on bad input';
dies_ok { WebGUI::Pluggable::load( 'uploads::ik::jo::ikjosdfwefsdfsefwef::myfile.txt\0.pm' ) } 'load dies on bad input';
dies_ok { WebGUI::Pluggable::load( 'HA::::HA' ) } 'load dies on bad input';
#----------------------------------------------------------------------------
# Test find and findAndLoad
{ # Block to localize @INC

View file

@ -354,8 +354,6 @@ cmp_deeply(
isa_ok( $driver->get(), 'HASH', 'get returns a hashref if called with no param');
note explain $driver->get();
is($driver->get('groupToUse'), 7, '... default group is 7');
$options = $driver->get();

View file

@ -140,7 +140,7 @@ cmp_deeply(
'create: requires a session variable',
);
my $now = WebGUI::DateTime->new($session, time);
my $now = time();
eval { $fence = WebGUI::Shop::Vendor->create($session, { userId => $fenceUser->userId, }); };
$e = Exception::Class->caught();
@ -152,9 +152,8 @@ is $fence->userId, $fenceUser->userId, 'object made with create has properties i
$fence->write;
ok($fence->get('dateCreated'), 'dateCreated is not null');
my $dateCreated = WebGUI::DateTime->new($session, $fence->get('dateCreated'));
my $deltaDC = $dateCreated - $now;
cmp_ok( $deltaDC->in_units('seconds'), '<=', 2, 'dateCreated is set properly');
my $deltaDC = $fence->dateCreated - $now;
cmp_ok( $deltaDC, '<=', 2, 'dateCreated is set properly');
#######################################################################
#

View file

@ -287,11 +287,11 @@ ok (!(-e $storage1->getPath("testfile-hash.file")), "rename file original file i
####################################################
$storage1->addFileFromFilesystem(
WebGUI::Test->getTestCollateralPath('International/lib/WebGUI/i18n/PigLatin/WebGUI.pm'),
WebGUI::Test->getTestCollateralPath('littleTextFile'),
);
ok(
grep(/WebGUI\.pm/, @{ $storage1->getFiles }),
grep(/littleTextFile/, @{ $storage1->getFiles }),
'addFileFromFilesystem: file added from test collateral area'
);
@ -312,7 +312,7 @@ cmp_bag($secondCopy->getFiles(), $storage1->getFiles(), 'copy: passing explicit
my $s3copy = WebGUI::Storage->create($session);
addToCleanup($s3copy);
my @filesToCopy = qw/WebGUI.pm testfile-hash-renamed.file/;
my @filesToCopy = qw/littleTextFile testfile-hash-renamed.file/;
$storage1->copy($s3copy, [@filesToCopy]);
cmp_bag($s3copy->getFiles(), [ @filesToCopy ], 'copy: passing explicit variable and files to copy');
{
@ -347,7 +347,7 @@ cmp_bag($s3copy->getFiles(), [ @filesToCopy ], 'copy: passing explicit variable
is(scalar @{ $storage1->getFiles }, 4, 'storage1 has 4 files');
is($storage1->deleteFile("testfile-hash-renamed.file"), 1, 'deleteFile: deleted 1 file');
is($storage1->deleteFile("testfile-hash-copied.file"), 1, 'deleteFile: deleted 1 file');
is($storage1->deleteFile("WebGUI.pm"), 1, 'deleteFile: deleted another file');
is($storage1->deleteFile("littleTextFile"), 1, 'deleteFile: deleted another file');
cmp_bag($storage1->getFiles, [$filename], 'deleteFile: storage1 has only 1 file');
##Test for out of object file deletion

View file

@ -57,7 +57,6 @@ my $nonRootLink = qr{
sub checkLinks {
my ($tag, $attrs) = @_;
if ($tag eq 'link' && $attrs->{href}) {
note sprintf '%s: %s', $tag, $attrs->{href};
if ($attrs->{href} !~ $nonRootLink) {
$validLinks = 0;
}

View file

@ -1,14 +0,0 @@
#-------------------------------------------------------------------
# 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 File::Spec::Functions qw( catdir rel2abs );
use File::Basename qw( dirname );
use Test::Class::Load rel2abs( catdir ( dirname( __FILE__ ), 'tests' ) );
Test::Class->runtests;

View file

@ -0,0 +1 @@
This is a little text file.