Conflicts: docs/gotcha.txt docs/previousVersion.sql docs/templates.txt lib/WebGUI.pm lib/WebGUI/Asset.pm lib/WebGUI/Asset/Event.pm lib/WebGUI/Asset/File.pm lib/WebGUI/Asset/MapPoint.pm lib/WebGUI/Asset/RichEdit.pm lib/WebGUI/Asset/Sku/Product.pm lib/WebGUI/Asset/Snippet.pm lib/WebGUI/Asset/Story.pm lib/WebGUI/Asset/Template.pm lib/WebGUI/Asset/Template/TemplateToolkit.pm lib/WebGUI/Asset/Wobject/Calendar.pm lib/WebGUI/Asset/Wobject/Carousel.pm lib/WebGUI/Asset/Wobject/Collaboration.pm lib/WebGUI/Asset/Wobject/Dashboard.pm lib/WebGUI/Asset/Wobject/DataForm.pm lib/WebGUI/Asset/Wobject/Folder.pm lib/WebGUI/Asset/Wobject/Map.pm lib/WebGUI/Asset/Wobject/Search.pm lib/WebGUI/Asset/Wobject/Shelf.pm lib/WebGUI/Asset/Wobject/StockData.pm lib/WebGUI/Asset/Wobject/StoryTopic.pm lib/WebGUI/Asset/Wobject/SyndicatedContent.pm lib/WebGUI/Asset/Wobject/Thingy.pm lib/WebGUI/Asset/Wobject/WeatherData.pm lib/WebGUI/AssetClipboard.pm lib/WebGUI/AssetCollateral/DataForm/Entry.pm lib/WebGUI/AssetExportHtml.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/AssetMetaData.pm lib/WebGUI/AssetTrash.pm lib/WebGUI/AssetVersioning.pm lib/WebGUI/Auth.pm lib/WebGUI/Cache/CHI.pm lib/WebGUI/Content/AssetManager.pm lib/WebGUI/Fork/ProgressBar.pm lib/WebGUI/Form/JsonTable.pm lib/WebGUI/Form/TimeField.pm lib/WebGUI/Form/Zipcode.pm lib/WebGUI/Group.pm lib/WebGUI/International.pm lib/WebGUI/Macro/AssetProxy.pm lib/WebGUI/Macro/FileUrl.pm lib/WebGUI/Operation/SSO.pm lib/WebGUI/Operation/User.pm lib/WebGUI/Role/Asset/Subscribable.pm lib/WebGUI/Shop/Cart.pm lib/WebGUI/Shop/Transaction.pm lib/WebGUI/Shop/TransactionItem.pm lib/WebGUI/Test.pm lib/WebGUI/URL/Content.pm lib/WebGUI/URL/Uploads.pm lib/WebGUI/User.pm lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm lib/WebGUI/Workflow/Activity/SendNewsletters.pm lib/WebGUI/i18n/English/Asset.pm lib/WebGUI/i18n/English/WebGUI.pm sbin/installClass.pl sbin/rebuildLineage.pl sbin/search.pl sbin/testEnvironment.pl t/Asset/Asset.t t/Asset/AssetClipboard.t t/Asset/AssetLineage.t t/Asset/AssetMetaData.t t/Asset/Event.t t/Asset/File.t t/Asset/File/Image.t t/Asset/Post/notification.t t/Asset/Sku.t t/Asset/Story.t t/Asset/Template.t t/Asset/Wobject/Collaboration/templateVariables.t t/Asset/Wobject/Collaboration/unarchiveAll.t t/Asset/Wobject/Shelf.t t/Auth.t t/Macro/EditableToggle.t t/Macro/FilePump.t t/Shop/Cart.t t/Shop/Transaction.t t/Storage.t t/User.t t/Workflow.t
127 lines
4.4 KiB
Perl
127 lines
4.4 KiB
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
|
|
#-------------------------------------------------------------------
|
|
|
|
use strict;
|
|
|
|
##The goal of this test is to test the creation of Snippet Assets.
|
|
|
|
use WebGUI::Test;
|
|
use WebGUI::Session;
|
|
use Test::More tests => 21; # increment this value for each test you create
|
|
use Test::Exception;
|
|
use WebGUI::Asset::Snippet;
|
|
|
|
my $session = WebGUI::Test->session;
|
|
my $node = WebGUI::Asset->getImportNode($session);
|
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
|
$versionTag->set({name=>"Snippet Test"});
|
|
my %tag = ( tagId => $versionTag->getId, status => "pending" );
|
|
addToCleanup($versionTag);
|
|
my $snippet = $node->addChild({className=>'WebGUI::Asset::Snippet', %tag});
|
|
|
|
# Test for a sane object type
|
|
isa_ok($snippet, 'WebGUI::Asset::Snippet');
|
|
|
|
# Test to see if we can set values
|
|
my $properties = {
|
|
cacheTimeout => 124,
|
|
templateParser => 'WebGUI::Asset::Template::HTMLTemplate',
|
|
mimeType => 'text/plain',
|
|
snippet => "Gooey's milkshake brings all the girls to the yard...",
|
|
};
|
|
$snippet->update($properties);
|
|
|
|
foreach my $property (keys %{$properties}) {
|
|
is ($snippet->get($property), $properties->{$property}, "updated $property is ".$properties->{$property});
|
|
}
|
|
|
|
# Rudimentry test of the view method
|
|
my $output = $snippet->view;
|
|
|
|
# See if cache purges on update
|
|
$snippet->update({snippet=>"I pitty tha fool!"});
|
|
like($snippet->view, qr/I pitty tha fool/,"cache for view method purges on update");
|
|
like($snippet->www_view,qr/I pitty tha fool/,"cache for www_view method purges on update");
|
|
|
|
# It should return something
|
|
isnt ($output, undef, 'view method returns something');
|
|
|
|
# What about our snippet?
|
|
ok ($output =~ /Gooey's milkshake brings all the girls to the yard\.\.\./, 'view method output has our snippet in it');
|
|
|
|
my $wwwViewOutput = $snippet->www_view;
|
|
isnt ($wwwViewOutput, undef, 'www_view returns something');
|
|
|
|
my $editOutput = $snippet->www_edit;
|
|
isnt ($editOutput, undef, 'www_edit returns something');
|
|
|
|
$snippet->update({
|
|
title => "authMethod",
|
|
templateParser => 'WebGUI::Asset::Template::TemplateToolkit',
|
|
cacheTimeout => 1,
|
|
snippet => q|^SQL(select value from settings where name="[% title %]");|
|
|
});
|
|
|
|
$session->config->addToHash('macros', 'SQL', 'SQL');
|
|
|
|
is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in the correct order');
|
|
|
|
my $empty = $node->addChild( { className => 'WebGUI::Asset::Snippet', %tag } );
|
|
is($empty->www_view, 'empty', 'www_view: snippet with no content returns "empty"');
|
|
|
|
#----------------------------------------------------------------------
|
|
#Check caching
|
|
|
|
##Set up the snippet to do caching
|
|
$snippet->update({
|
|
cacheTimeout => 100,
|
|
snippet => 'Cache test: ^#;',
|
|
});
|
|
|
|
$versionTag->commit;
|
|
|
|
is $snippet->view, 'Cache test: 1', 'validate snippet content and set cache';
|
|
$session->user({userId => 3});
|
|
is $snippet->view(1), 'Cache test: 3', 'receive uncached content since view was passed the webMethod flag';
|
|
|
|
#----------------------------------------------------------------------
|
|
#Check packing
|
|
|
|
my $tag2 = WebGUI::VersionTag->getWorking($session);
|
|
$tag{tagId} = $tag2->getId;
|
|
my $snippet2 = $node->addChild({className => 'WebGUI::Asset::Snippet', %tag});
|
|
$snippet2->update({mimeType => 'text/javascript'});
|
|
$tag2->commit;
|
|
addToCleanup($tag2);
|
|
|
|
$snippet2->snippet('uncompressable');
|
|
is $snippet2->snippetPacked, 'uncompressable', 'packed snippet content was set';
|
|
|
|
$snippet2->snippet("two\n\nwords");
|
|
is $snippet2->snippetPacked, "two words", '... and packed';
|
|
|
|
open my $JSFILE, WebGUI::Test->getTestCollateralPath('jquery.js')
|
|
or die "Unable to open jquery test collateral file: $!";
|
|
my $jquery;
|
|
{
|
|
undef $/;
|
|
$jquery = <$JSFILE>;
|
|
};
|
|
close $JSFILE;
|
|
|
|
$snippet2 = $snippet2->cloneFromDb;
|
|
is $snippet2->get('snippetPacked'), undef, 'no packed content';
|
|
lives_ok { $snippet2->update({snippet => $jquery}); } 'did not die during packing jquery';
|
|
ok $snippet2->get('snippetPacked'), 'snippet content was packed';
|
|
|
|
TODO: {
|
|
local $TODO = "Tests to make later";
|
|
ok(0, 'Test indexContent method');
|
|
}
|