Merge commit '41575d24bb' into webgui8. Some tests still failing.

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/Template.pm
	lib/WebGUI/Asset/WikiPage.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/Cache.pm
	lib/WebGUI/Content/Setup.pm
	lib/WebGUI/Role/Asset/Subscribable.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/Pay.pm
	lib/WebGUI/Shop/PayDriver/ITransact.pm
	sbin/testEnvironment.pl
	t/Asset/WikiPage.t
	t/Shop/PayDriver.t
	t/Shop/PayDriver/ITransact.t
	t/Shop/PayDriver/Ogone.t
	t/Shop/TaxDriver/EU.t
	t/Shop/TaxDriver/Generic.t
	t/Workflow/Activity/RemoveOldCarts.t
	t/lib/WebGUI/Test.pm
This commit is contained in:
Colin Kuskie 2010-06-25 23:25:26 -07:00
commit 5febc0ebbc
258 changed files with 5528 additions and 2230 deletions

View file

@ -35,7 +35,7 @@ my $session = WebGUI::Test->session;
my @getTitleTests = getTitleTests($session);
plan tests => 121
plan tests => 120
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
;
@ -298,8 +298,8 @@ $versionTag->commit;
$session->setting->set('urlExtension', undef);
is($importNode->fixUrl('1234'.'-'x235 . 'abcdefghij'), '1234'.'-'x235 . 'abcdefghij', 'fixUrl leaves long URLs under 250 characters alone');
is($importNode->fixUrl('1234'.'-'x250 . 'abcdefghij'), '1234'.'-'x216, 'fixUrl truncates long URLs over 250 characters to 220 characters');
is($importNode->fixUrl('1234'.'_'x235 . 'abcdefghij'), '1234'.'_'x235 . 'abcdefghij', 'fixUrl leaves long URLs under 250 characters alone');
is($importNode->fixUrl('1234'.'_'x250 . 'abcdefghij'), '1234'.'_'x216, 'fixUrl truncates long URLs over 250 characters to 220 characters');
$session->config->set('extrasURL', '/extras');
$session->config->set('uploadsURL', '/uploads');
@ -446,52 +446,11 @@ $session->config->set('assets/WebGUI::Asset::Snippet/uiLevel', 8);
is($fixTitleAsset->getUiLevel, 8, 'getUiLevel: Snippet has a configured uiLevel of 8');
################################################################
#
# assetExists
#
################################################################
{
my $id = $canViewAsset->getId;
my $class = 'WebGUI::Asset';
my $date = $canViewAsset->get('revisionDate');
ok ( WebGUI::Asset->assetExists($session, $id, $class, $date), 'assetExists with proper class, id and revisionDate');
ok (!WebGUI::Asset->assetExists($session, $id, 'WebGUI::Asset::Snippet', $date), 'assetExists with wrong class does not exist');
my $id2 = $id;
++$id2;
ok (!WebGUI::Asset->assetExists($session, $id2, $class, $date), 'assetExists with wrong id does not exist');
ok (!WebGUI::Asset->assetExists($session, $id, $class, $date+1), 'assetExists with wrong revisionDate does not exist');
}
################################################################
#
# getEditTabs
#
################################################################
#my @tabs = $canViewAsset->getEditTabs;
#is(scalar(@tabs), 4, 'getEditTabs: 4 tabs by default');
################################################################
#
# getEditForm
#
################################################################
$session->style->sent(0); ##Prevent extra output from being generated by session->style
##At some point, a test will need to tie STDOUT and make sure
##that the output is correct.
#isa_ok($canViewAsset->getEditForm, 'WebGUI::TabForm', 'getEditForm: Returns a tabForm');
TODO: {
local $TODO = 'More getEditForm tests';
ok(0, 'Validate form output');
}
################################################################
#
# getNotFound

View file

@ -0,0 +1,133 @@
#-------------------------------------------------------------------
# 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";
# Test the 'adjustOrientation' method called by 'applyConstraints'. It is
# responsible for rotating JPEG images according to orientation information
# in EXIF data (if present). A number of test images have been created for
# this purpose which are checked based on dimensions and pixel-wise.
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Asset::File::GalleryFile::Photo;
use Image::Magick;
use Test::More;
use Test::Deep;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
# Name version tag and make sure it gets cleaned up
$versionTag->set({name=>"Orientation adjustment test"});
addToCleanup($versionTag);
# Create gallery and a single album
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1024x768",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Create single photo inside the album
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Commit all changes
$versionTag->commit;
#----------------------------------------------------------------------------
# Tests
plan tests => 8;
#----------------------------------------------------------------------------
# Test adjustment of image with orientation set to 1
$photo->setFile( WebGUI::Test->getTestCollateralPath('orientation_1.jpg') );
my $storage = $photo->getStorageLocation;
# Check dimensions
cmp_deeply( [ $storage->getSizeInPixels($photo->get('filename')) ], [2, 3], "Check if image with orientation 1 was left as is (based on dimensions)" );
# Check single pixel
my $image = new Image::Magick;
$image->Read( $storage->getPath( $photo->get('filename') ) );
cmp_deeply( [ $image->GetPixel( x=>1, y=>1 ) ], [ 1, 1, 1], "Check if image with orientation 1 was left as is (based on pixel values)");
#----------------------------------------------------------------------------
# Test adjustment of image with orientation set to 3
# Attach new image to Photo asset
$photo->setFile( WebGUI::Test->getTestCollateralPath('orientation_3.jpg') );
my $storage = $photo->getStorageLocation;
# Check dimensions
cmp_deeply( [ $storage->getSizeInPixels($photo->get('filename')) ], [2, 3], "Check if image with orientation 3 was rotated by 180° (based on dimensions)" );
# Check single pixel
$image->Read( $storage->getPath( $photo->get('filename') ) );
cmp_deeply( [ $image->GetPixel( x=>2, y=>3 ) ], [ 1, 1, 1], "Check if image with orientation 3 was rotated by 180° (based on pixels)");
#----------------------------------------------------------------------------
# Test adjustment of image with orientation set to 6
# Attach new image to Photo asset
$photo->setFile( WebGUI::Test->getTestCollateralPath('orientation_6.jpg') );
my $storage = $photo->getStorageLocation;
# Check dimensions
cmp_deeply( [ $storage->getSizeInPixels($photo->get('filename')) ], [3, 2], "Check if image with orientation 6 was rotated by 90° CW (based on dimensions)" );
# Check single pixel
$image->Read( $storage->getPath( $photo->get('filename') ) );
cmp_deeply( [ $image->GetPixel( x=>3, y=>1 ) ], [ 1, 1, 1], "Check if image with orientation 6 was rotated by 90° CW (based on pixels)");
#----------------------------------------------------------------------------
# Test adjustment of image with orientation set to 8
# Attach new image to Photo asset
$photo->setFile( WebGUI::Test->getTestCollateralPath('orientation_8.jpg') );
my $storage = $photo->getStorageLocation;
# Check dimensions
cmp_deeply( [ $storage->getSizeInPixels($photo->get('filename')) ], [3, 2], "Check if image with orientation 8 was rotated by 90° CCW (based on dimensions)" );
# Check single pixel
$image->Read( $storage->getPath( $photo->get('filename') ) );
cmp_deeply( [ $image->GetPixel( x=>1, y=>2 ) ], [ 1, 1, 1], "Check if image with orientation 8 was rotated by 90° CCW (based on pixels)");

View file

@ -128,6 +128,9 @@ my $testTemplateVars = {
lastFile_thumbnailUrl
=> $nextPhoto->getThumbnailUrl,
lastFile_title => $nextPhoto->get("title"),
ownerAlias => 'Admin',
ownerId => '3',
ownerProfileUrl => '/?op=account;module=profile;do=view;uid=3',
};
# Ignore all EXIF tags, they're tested in exif.t

View file

@ -19,7 +19,7 @@ use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 16; # increment this value for each test you create
use Test::More tests => 17; # increment this value for each test you create
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Post;
use WebGUI::Asset::Post::Thread;
@ -114,6 +114,7 @@ ok($post->canEdit(), "User in groupIdEditUserGroup group can edit post after the
#
######################################################################
can_ok($post, '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');

View file

@ -71,6 +71,9 @@ my $topic = $defaultNode->addChild({
my $archiveTag = WebGUI::VersionTag->getWorking($session);
$archiveTag->commit;
WebGUI::Test->addToCleanup($archiveTag);
foreach my $asset ($archive, $topic) {
$asset = $asset->cloneFromDb;
}
my $storage1 = WebGUI::Storage->create($session);
my $storage2 = WebGUI::Storage->create($session);
@ -271,9 +274,11 @@ cmp_deeply(
{
title => 'Story 1',
description => 'WebGUI was originally called Web Done Right.',
'link' => re('story-1$'),
'link' => all(re('^'.$session->url->getSiteURL),re('story-1$')),
guid => re('story-1$'),
author => 'JT Smith',
date => $story->lastModified,
pubDate => $session->datetime->epochToMail($story->get('creationDate')),
},
'getRssData: returns correct data'
);

View file

@ -16,7 +16,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 29; # increment this value for each test you create
use Test::More tests => 18; # increment this value for each test you create
use Test::Deep;
use WebGUI::Asset::Wobject::WikiMaster;
use WebGUI::Asset::WikiPage;
@ -96,57 +96,4 @@ $comments = $wikipage->get('comments');
is($comments->[0]{comment}, $secondComment, "you can delete a comment");
is($wikipage->get('averageCommentRating'), 1, 'average rating is adjusted after deleting a comment');
##################
# This section tests hierarchical keywords support
##################
#
## setup some more wiki pages
my $properties = {
className=>'WebGUI::Asset::WikiPage',
content => 'Now is the time for all good men to come to the aid of their country',
title => 'Keyword',
keywords => 'keyword'
};
my $wikipage2 = $wiki->addChild($properties, @autoCommitCoda);
isa_ok($wikipage2, 'WebGUI::Asset::WikiPage');
$properties = {
className=>'WebGUI::Asset::WikiPage',
content => 'The quick brown fox jumps over the lazy dog.',
title => 'Fox',
keywords => 'keyword'
};
my $wikipage3 = $wiki->addChild($properties, @autoCommitCoda);
isa_ok($wikipage3, 'WebGUI::Asset::WikiPage');
# Test keywords support
my $keywords = $wikipage2->get('keywords');
is($keywords,$properties->{'keywords'}, 'Keywords match');
# Test isKeywordPage()
ok $wikipage2->isKeywordPage(), "'".$wikipage2->get('title')."' is a keyword page";
my $templateVars = $wikipage2->getTemplateVars;
ok $templateVars->{isKeywordPage}, 'isKeywordPage template var, true';
cmp_deeply
$templateVars->{keyword_page_loop},
[
{ title => 'Fox', url => '/wikitest/fox', },
],
'populated keyword_page_loop, sorted by title';
ok ! $wikipage3->isKeywordPage(), "'".$wikipage3->get('title')."' is not a keyword page";
$templateVars = $wikipage3->getTemplateVars;
ok ! $templateVars->{isKeywordPage}, 'isKeywordPage template var, false';
cmp_deeply $templateVars->{keyword_page_loop}, [], 'empty keyword_page_loop';
$wikipage3->update({keywords => $wikipage3->get('keywords').',Fox'});
ok $wikipage3->isKeywordPage(), "'".$wikipage3->get('title')."' is now a keyword page";
$templateVars = $wikipage3->getTemplateVars;
ok $templateVars->{isKeywordPage}, 'isKeywordPage template var, false';
cmp_deeply
$templateVars->{keyword_page_loop},
[ ],
'empty keyword_page_loop, self is not put into the loop';
#vim:ft=perl
can_ok($wikipage, 'getSynopsisAndContent');

View file

@ -548,6 +548,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
pubDate => ignore(),
guid => ignore(),
},
{
title => 'Story 2',
@ -555,6 +557,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
pubDate => ignore(),
guid => ignore(),
},
{
title => 'Story 3',
@ -562,6 +566,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
pubDate => ignore(),
guid => ignore(),
},
],
'rssFeedItems'

View file

@ -297,6 +297,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
pubDate => ignore(),
guid => ignore(),
},
{
title => 'red',
@ -304,6 +306,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
pubDate => ignore(),
guid => ignore(),
},
{
title => 'brooks',
@ -311,6 +315,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
pubDate => ignore(),
guid => ignore(),
},
],
'rssFeedItems'

View file

@ -85,8 +85,9 @@ my $variables = $wiki->getKeywordVariables($hierarchy);
cmp_deeply(
$hierarchy->[0],
{
title => 'criminals',
url => '/testwiki/criminals',
title => 'criminals',
url => '/testwiki?func=byKeyword;keyword=criminals',
descendants => 0,
},
"getKeywordVariables, does not alter the original hierarchy passed in",
);
@ -96,21 +97,27 @@ cmp_deeply(
[
{
title => 'criminals',
url => '/testwiki/criminals',
url => '/testwiki?func=byKeyword;keyword=criminals',
level => 0,
indent_loop => [],
descendants => 0,
isTopLevel => 1,
},
{
title => 'inmates',
url => '/testwiki/inmates',
url => '/testwiki?func=byKeyword;keyword=inmates',
level => 0,
indent_loop => [],
descendants => 0,
isTopLevel => 1,
},
{
title => 'staff',
url => '/testwiki/staff',
url => '/testwiki?func=byKeyword;keyword=staff',
level => 0,
indent_loop => [],
descendants => 0,
isTopLevel => 1,
},
],
"... variables",
@ -133,9 +140,9 @@ cmp_deeply(
);
$wiki->update({topLevelKeywords => 'criminals,inmates,staff'});
$page_set{criminals}->update({keywords => 'red,andy'});
$page_set{inmates}->update({keywords => 'brooks,heywood'});
$page_set{staff}->update({keywords => 'norton,hadley'});
$wiki->setSubKeywords('criminals', 'red', 'andy');
$wiki->setSubKeywords('inmates', 'brooks', 'heywood');
$wiki->setSubKeywords('staff', 'norton', 'hadley');
foreach my $title (qw/red andy brooks heywood norton hadley/) {
$page_set{$title} = $wiki->addChild({
@ -152,33 +159,36 @@ cmp_bag(
$wiki->getKeywordHierarchy(),
[
{
title => 'criminals', url => '/testwiki/criminals',
title => 'criminals', url => '/testwiki?func=byKeyword;keyword=criminals',
children => bag(
superhashof({ title => 'red', }),
superhashof({ title => 'andy', }),
),
descendants => 0,
},
{
title => 'inmates', url => '/testwiki/inmates',
title => 'inmates', url => '/testwiki?func=byKeyword;keyword=inmates',
children => bag(
superhashof({ title => 'heywood', }),
superhashof({ title => 'brooks', }),
),
descendants => 0,
},
{
title => 'staff', url => '/testwiki/staff',
title => 'staff', url => '/testwiki?func=byKeyword;keyword=staff',
children => bag(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }),
),
descendants => 0,
},
],
"getKeywordHierarchy: simple hierarchy",
);
##Check depth-first display, and try to make a keyword loop
$page_set{andy}->update({keywords => 'criminals,inmates'});
$page_set{brooks}->update({keywords => 'criminals'});
$wiki->setSubKeywords('andy', 'criminals', 'inmates');
$wiki->setSubKeywords('brooks', 'criminals');
my $tag_set3 = WebGUI::VersionTag->getWorking($session);
$tag_set3->commit;
@ -238,9 +248,9 @@ cmp_deeply(
},
]),
[
{ title => 'title 0', url => 'url 0', level => 0, indent_loop => [], },
{ title => 'title 1', url => 'url 1', level => 1, indent_loop => [{indent => 1}], },
{ title => 'title 2', url => 'url 2', level => 2, indent_loop => [{indent => 1,}, {indent => 2,},], },
{ title => 'title 0', url => 'url 0', level => 0, isTopLevel => 1, indent_loop => [], },
{ title => 'title 1', url => 'url 1', level => 1, isTopLevel => '', indent_loop => [{indent => 1}], },
{ title => 'title 2', url => 'url 2', level => 2, isTopLevel => '', indent_loop => [{indent => 1,}, {indent => 2,},], },
],
'getKeywordVariables: checking deeply'
);