Merge commit 'f2e0fb509a' into WebGUI8. Some tests still failing.

This commit is contained in:
Colin Kuskie 2010-06-27 22:32:31 -07:00
commit 385931aaab
92 changed files with 1966 additions and 650 deletions

View file

@ -23,7 +23,7 @@ use WebGUI::VersionTag;
use Test::More; # increment this value for each test you create
use Test::MockObject;
plan tests => 14;
plan tests => 16;
my $session = WebGUI::Test->session;
$session->user({userId => 3});
@ -127,6 +127,30 @@ cmp_ok( $updatedSnippet->get('revisionDate'), '>', $snippetRev->get('revisionDat
my $lastTag = WebGUI::VersionTag->getWorking($session);
WebGUI::Test->addToCleanup($lastTag);
{
# Test clearPackageFlag
my $flagTag = WebGUI::VersionTag->create($session);
WebGUI::Test->addToCleanup($flagTag);
$flagTag->setWorking;
my $tempspace = WebGUI::Asset->getTempspace($session);
my $snippet = $tempspace->addChild(
{ url => 'pflagt',
title => 'package flag test',
menuTitle => 'package flag test',
className => 'WebGUI::Asset::Snippet',
snippet => 'This is a test asset',
isPackage => 1,
}
);
my $storage = $snippet->exportPackage;
WebGUI::Test->addToCleanup($storage);
my $without = $tempspace->importPackage($storage);
ok $without->get('isPackage'), 'has flag with no option';
my $with = $tempspace->importPackage($storage, { clearPackageFlag => 1 });
ok !$with->get('isPackage'), 'no flag with option';
}
TODO: {
local $TODO = "Tests to make later";
ok(0, 'Check package deployment with 2-level package and look for new style templates propagating down the tree');

View file

@ -24,15 +24,20 @@ use WebGUI::Asset::File::GalleryFile::Photo;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $user = WebGUI::User->new( $session, 3 );
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Photo Test"});
addToCleanup($versionTag);
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
groupIdAddComment => 7, # Everyone
groupIdAddFile => 2, # Registered Users
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
@ -42,36 +47,40 @@ my $album
{
skipAutoCommitWorkflows => 1,
});
my $previousPhoto
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
ownerUserId => 3,
ownerUserId => $user->getId,
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
ownerUserId => 3,
ownerUserId => $user->getId,
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $nextPhoto
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
ownerUserId => 3,
ownerUserId => $user->getId,
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
$versionTag->commit;
foreach my $asset ($gallery, $album, $photo) {
$asset = $asset->cloneFromDb;
@ -91,7 +100,10 @@ my $testTemplateVars = {
synopsis => '', # Synopsis is not undef, is changed to empty string
canComment => bool( 1 ),
canEdit => bool( 0 ),
ownerUsername => WebGUI::User->new( $session, 3 )->username,
ownerUsername => $user->get("username"),
ownerAlias => $user->get("alias") || $user->get("username"),
ownerId => $user->getId,
ownerProfileUrl => $user->getProfileUrl,
synopsis_textonly => WebGUI::HTML::filter( $photo->get('synopsis'), "all" ),
url => $photo->getUrl,
url_addArchive => $album->getUrl('func=addArchive'),

View file

@ -275,8 +275,10 @@ cmp_deeply(
title => 'Story 1',
description => 'WebGUI was originally called Web Done Right.',
'link' => re('story-1$'),
guid => re('story-1$'),
author => 'JT Smith',
date => $story->lastModified,
pubDate => $session->datetime->epochToMail($story->creationDate),
},
'getRssData: returns correct data'
);

View file

@ -75,7 +75,7 @@ my $template3 = $importNode->addChild({
className => "WebGUI::Asset::Template",
title => 'headBlock test',
template => "this is a template",
});
}, undef, time()-5);
my @atts = (
{type => 'headScript', sequence => 1, url => 'bar'},
@ -97,7 +97,7 @@ ok(exists $session->style->{_javascript}->{$_}, "$_ in style") for qw(foo bar bo
# revision-ness of attachments
# sleep so the revisiondate isn't duplicated
sleep 1;
#sleep 1;
my $template3dup = $template3->duplicate;
my @atts3dup = map { delete @{ $_ }{qw/attachId templateId revisionDate/}; $_; } @{ $template3dup->getAttachments };

View file

@ -0,0 +1,318 @@
#-------------------------------------------------------------------
# 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 of the Gallery basic and advanced search. In non-live tests, the Gallery
# search is accessed via the "search" method. Form parameters are passed in via
# the pseudo request object of the test session.
use Test::More;
use Test::Deep;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Asset::Wobject::Gallery;
use WebGUI::Asset::Wobject::GalleryAlbum;
use WebGUI::Asset::File::GalleryFile::Photo;
use WebGUI::DateTime;
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set( { name=>"Gallery Search Test" } );
addToCleanup( $versionTag );
# Create gallery and a single album
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
title => "album",
synopsis => "synopsis2",
keywords => "group2",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $albumId = $album->getId;
# Populate album with different photos
my $photo1
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
title => "photo1",
synopsis => "synopsis1",
keywords => "group1",
location => "Heidelberg",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $id1 = $photo1->getId;
my $photo2
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
title => "photo2",
synopsis => "synopsis2",
keywords => "group1",
location => "Mannheim",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $id2 = $photo2->getId;
my $photo3
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
title => "photo3",
synopsis => "synopsis1",
keywords => "group2",
location => "Mannheim",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $id3 = $photo3->getId;
# Commit all changes
$versionTag->commit;
# Make gallery default asset
$session->asset( $gallery );
# Define some general variables
my $result;
#----------------------------------------------------------------------------
# Tests
plan tests => 32;
#----------------------------------------------------------------------------
# Basic search
note( "Basic gallery search" );
# Search by title
my $hits = search( { basicSearch => "album" } );
# Basic search will behave differently from advanced search. The album and all
# photos of the album will be returned, since the name of the album is added to
# index keywords of photos.
cmp_bag( $hits, [ $albumId, $id1, $id2, $id3 ], "Search for album entitled 'album' (basic search)" );
my $hits = search( { basicSearch => "photo1" } );
cmp_bag( $hits, [ $id1 ], "Search for photo entitled 'photo1' (basic search)" );
my $hits = search( { title => "photo4" } );
cmp_bag( $hits, [ ], "Search for non-existing photo entitled 'photo4' (basic search)" );
# Search by keywords
my $hits = search( { basicSearch => "group1" } );
cmp_bag( $hits, [ $id1, $id2 ], "Search for albums/photos with keywords 'group1' (basic search)" );
my $hits = search( { basicSearch => "group2" } );
cmp_bag( $hits, [ $albumId, $id3 ], "Search for albums/photos with keywords 'group2' (basic search)" );
# Search by description
my $hits = search( { basicSearch => "synopsis1" } );
cmp_bag( $hits, [ $id1, $id3 ], "Search for albums/photos with synopsis 'synopsis1' (basic search)" );
my $hits = search( { basicSearch => "synopsis2" } );
cmp_bag( $hits, [ $albumId, $id2 ], "Search for albums/photos with synopsis 'synopsis2' (basic search)" );
# Warning: Tried to use 'here' and 'there' as locations for the following test.
# For unknown reasons the test failed. It seems that these and possibly other
# keywords are either filtered out by MySQL and/or are reserved words. Needs to
# be checked!!!
my $hits = search( { basicSearch => "Mannheim" } );
cmp_bag( $hits, [ $id2, $id3 ], "Search for photos taken at location 'Mannheim' (basic search)" );
my $hits = search( { basicSearch => "Heidelberg" } );
cmp_bag( $hits, [ $id1 ], "Search for photos taken at location 'Heidelberg' (basic search)" );
# Search by multiple criteria
my $hits = search({ basicSearch => "group1 synopsis1" });
cmp_bag( $hits, [ $id1 ], "Search for photo with keywords 'group1' and synopsis 'synopsis1' (basic search)" );
my $hits = search({ basicSearch => "group2 Mannheim" });
cmp_bag( $hits, [ $id3 ], "Search for photo with keywords 'group2' and location 'Mannheim' (basic search)" );
my $hits = search({ basicSearch => "synopsis1 Mannheim" });
cmp_bag( $hits, [ $id3 ], "Search for photo with synopsis 'synopsis1' and location 'Mannheim' (basic search)" );
#----------------------------------------------------------------------------
# Advanced search
note( "Advanced gallery search" );
my $hits = search( { } );
cmp_bag( $hits, [ ], "Empty search (advanced search)" );
# Search by class
my $hits = search( { className => "WebGUI::Asset::File::GalleryFile::Photo" } );
cmp_bag( $hits, [ $id1, $id2, $id3 ], "Search for all photos (advanced search)" );
my $hits = search( { className => "WebGUI::Asset::Wobject::GalleryAlbum" } );
cmp_bag( $hits, [ $albumId ], "Search for all albums (advanced search)" );
# Search by date
my $oneYearAgo = WebGUI::DateTime->new( $session, time )->add( years => -1 )->epoch;
my $hits
= search({
creationDate_after => $oneYearAgo,
creationDate_before => time(),
});
cmp_bag( $hits, [ $albumId, $id1, $id2, $id3 ], "Search by date, all included (advanced search)" );
my $hits
= search({
creationDate_after => time() + 1,
creationDate_before => time() + 1,
});
cmp_bag( $hits, [ ], "Search by date, all excluded (advanced search)" );
# Search by title
my $hits = search( { title => "album" } );
cmp_bag( $hits, [ $albumId ], "Search for album entitled 'album' (advanced search)" );
my $hits = search( { title => "photo1" } );
cmp_bag( $hits, [ $id1 ], "Search for photo entitled 'photo1' (advanced search)" );
my $hits = search( { title => "photo4" } );
cmp_bag( $hits, [ ], "Search for non-existing photo entitled 'photo4' (advanced search)" );
# Search by keywords
my $hits = search( { keywords => "group1" } );
cmp_bag( $hits, [ $id1, $id2 ], "Search for albums/photos with keywords 'group1' (advanced search)" );
my $hits = search( { keywords => "group2" } );
cmp_bag( $hits, [ $albumId, $id3 ], "Search for albums/photos with keywords 'group2' (advanced search)" );
my $hits = search( { keywords => "group3" } );
cmp_bag( $hits, [ ], "Search for non-existing albums/photos with keywords 'group3' (advanced search)" );
# Search by description
my $hits = search( { description => "synopsis1" } );
cmp_bag( $hits, [ $id1, $id3 ], "Search for albums/photos with synopsis 'synopsis1' (advanced search)" );
my $hits = search( { description => "synopsis2" } );
cmp_bag( $hits, [ $albumId, $id2 ], "Search for albums/photos with synopsis 'synopsis2' (advanced search)" );
my $hits = search( { description => "synopsis3" } );
cmp_bag( $hits, [ ], "Search for non-existing albums/photos with synopsis 'synopsis3' (advanced search)" );
# Search by location
# Warning: Tried to use 'here' and 'there' as locations for the following test.
# For unknown reasons the test failed. It seems that these and possibly other
# keywords are either filtered out by MySQL and/or are reserved words. Needs to
# be checked!!!
my $hits = search( { location => "Mannheim" } );
cmp_bag( $hits, [ $id2, $id3 ], "Search for photos taken at location 'Mannheim' (advanced search)" );
my $hits = search( { location => "Heidelberg" } );
cmp_bag( $hits, [ $id1 ], "Search for photos taken at location 'Heidelberg' (advanced search)" );
my $hits = search( { location => "Frankfurt" } );
cmp_bag( $hits, [ ], "Search for non-existing photos taken at location 'Frankfurt' (advanced search)" );
# Search by multiple criteria
my $hits
= search({
keywords => "group1",
description => "synopsis1",
});
cmp_bag( $hits, [ $id1 ], "Search for photo with keywords 'group1' and synopsis 'synopsis1' (advanced search)" );
my $hits
= search({
keywords => "group2",
location => "Mannheim",
});
cmp_bag( $hits, [ $id3 ], "Search for photo with keywords 'group2' and location 'Mannheim' (advanced search)" );
my $hits
= search({
description => "synopsis1",
location => "Mannheim",
});
cmp_bag( $hits, [ $id3 ], "Search for photo with synopsis 'synopsis1' and location 'Mannheim' (advanced search)" );
#----------------------------------------------------------------------------
# search( formParams )
# Execute a search for photos and albums in the test gallery.
#
# Accepts a hash ref as single parameter. All key/value pairs in the hash are
# added as form parameters to the pseudo request object before the search is
# executed. See the Gallery search method for valid form fields.
#
# Returns a reference pointing an array containg the asset Ids of all hits.
sub search {
my $formParams = shift;
my $hits = [];
# Setup the mock request object
$session->request->method( 'GET' );
$session->request->setup_param( $formParams );
# Call gallery search function
my ( $paginator, $keywords ) = $gallery->search;
# Return ref to empty array if search could not be executed
return $hits unless $paginator;
# Extract asset Ids from search results and compile array.
for ( my $i = 1; $i <= $paginator->getNumberOfPages; $i++ ) {
for my $result ( @{ $paginator->getPageData( $i ) } ) {
push @{ $hits }, $result->{ assetId };
}
}
return $hits;
}

View file

@ -544,6 +544,8 @@ cmp_deeply(
description => ignore(),
'link' => ignore(),
date => ignore(),
guid => ignore(),
pubDate => ignore(),
author => ignore(),
},
{
@ -552,6 +554,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
guid => ignore(),
pubDate => ignore(),
},
{
title => 'Story 3',
@ -559,6 +563,8 @@ cmp_deeply(
'link' => ignore(),
date => ignore(),
author => ignore(),
guid => ignore(),
pubDate => ignore(),
},
],
'rssFeedItems'

View file

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

View file

@ -276,37 +276,37 @@ cmp_deeply(
[
{
'extras' => undef,
'url' => '/home?func=edit',
'url' => re('func=edit$'),
'label' => 'Edit'
},
{
'extras' => undef,
'url' => '/home?func=editSurvey',
'url' => re('func=editSurvey$'),
'label' => 'Edit Survey'
},
{
'extras' => undef,
'url' => '/home?func=takeSurvey',
'url' => re('func=takeSurvey$'),
'label' => 'Take Survey'
},
{
'extras' => undef,
'url' => '/home?func=graph',
'url' => re('func=graph$'),
'label' => 'Visualize'
},
{
'extras' => undef,
'url' => '/home?func=editTestSuite',
'url' => re('func=editTestSuite$'),
'label' => 'Test Suite'
},
{
'extras' => undef,
'url' => '/home?func=runTests',
'url' => re('func=runTests$'),
'label' => 'Run All Tests'
},
{
'extras' => undef,
'url' => '/home?func=runTests;format=tap',
'url' => re('func=runTests;format=tap$'),
'label' => 'Run All Tests (TAP)'
}
],

View file

@ -20,7 +20,7 @@ use Data::Dumper;
use WebGUI::Test;
use WebGUI::Session;
use Test::More tests => 27; # increment this value for each test you create
use Test::More tests => 29; # increment this value for each test you create
use Test::Deep;
use WebGUI::Asset::Wobject::SyndicatedContent;
use XML::FeedPP;
@ -175,7 +175,14 @@ is $vars->{item_loop}->[0]->{descriptionFirstParagraph},
'... first paragraph, when HTML is used';
is $vars->{item_loop}->[0]->{descriptionFirst2paragraphs},
"<p>In the attached feed, there is a hidden return line character from the Rich Text editor in the first sentence of the description. When using a Syndicated Content for the feed, the variable descriptionFirstParagraph variable cuts off at this return line character, creating invalid markup.</p><p>No more text is shown of the first paragraph beyond the bold characters of the first line.</p>",
'... first paragraph, when HTML is used';
'... first two paragraphs, when HTML is used';
is $vars->{item_loop}->[0]->{descriptionFirst10words},
"In the attached feed, there is a hidden return line ",
'... first 10 words, with HTML stripped';
is $vars->{item_loop}->[0]->{descriptionFirstSentence},
"In the attached feed, there is a hidden return line character from the
Rich Text editor in the first sentence of the description.",
'... first sentence, with HTML stripped';
####################################################################
#