From 6cf1afc6a7188f79f61ff9dd5ca6ce4d0fe42fea Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 10 Oct 2006 23:10:31 +0000 Subject: [PATCH] Add more POD to Style.pm to document that sent is set to true after this method is called. Add tests to check personalStyleTemplate and sent inside process method. --- lib/WebGUI/Session/Style.pm | 2 ++ t/Session/Style.t | 44 ++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm index d58909fd3..4c775f677 100644 --- a/lib/WebGUI/Session/Style.pm +++ b/lib/WebGUI/Session/Style.pm @@ -130,6 +130,8 @@ sub new { =head2 process ( content, templateId ) Returns a parsed style with content based upon the current WebGUI session information. +Sets the C method/flag to be true so that subsequent head data is processed +right away. =head3 content diff --git a/t/Session/Style.t b/t/Session/Style.t index 7bbb21b21..927cf90b9 100644 --- a/t/Session/Style.t +++ b/t/Session/Style.t @@ -15,8 +15,10 @@ use HTML::TokeParser; use WebGUI::Test; use WebGUI::Session; +use WebGUI::Asset; +use WebGUI::VersionTag; -use Test::More tests => 35; # increment this value for each test you create +use Test::More tests => 38; # increment this value for each test you create use Test::Deep; my $session = WebGUI::Test->session; @@ -152,10 +154,24 @@ is($macroOutput, 1, 'generateAdditionalHeadTags: process a macro'); # #################################################### +$style->sent(0); +is($style->sent, 0, 'process: setup sent to 0'); + is($style->process('body.content', 'notATemplateId'), "WebGUI was unable to instantiate your style template.body.content", 'process: invalid templateId returns error message to client'); +is($style->sent, 1, 'process: sets sent to 1'); + +my ($versionTag, $personalTemplate) = setup_assets($session); + +$session->scratch->set('personalStyleId', $personalTemplate->getId); + +my $styled = $style->process('body.content', 'notATemplateId'); +like($styled, +qr/PERSONAL STYLE TEMPLATE/, +'process: personalStyleTemplate overrides submitted template'); + sub simpleLinkParser { my ($tokenName, $text) = @_; my $p = HTML::TokeParser->new(\$text); @@ -175,6 +191,28 @@ sub simpleLinkParser { return ($url, $params); } - -END { + +sub setup_assets { + my $session = shift; + my $importNode = WebGUI::Asset->getImportNode($session); + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->set({name=>"Session Style test"}); + my $properties = { + title => 'personal style test template', + className => 'WebGUI::Asset::Template', + url => 'personal_style', + namespace => 'Style', + template => "PERSONAL STYLE TEMPLATE\n\nBODY=\n\nHEAD=", + id => 'testTemplate_personal1', + # '1234567890123456789012' + }; + my $template = $importNode->addChild($properties, $properties->{id}); + $versionTag->commit; + return ($versionTag, $template); +} + +END { + if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') { + $versionTag->rollback; + } }