adding test for headBlock processing in style templates. They should only show up once.

This commit is contained in:
Colin Kuskie 2007-01-07 22:42:13 +00:00
parent 600118b40a
commit c95fefec81

View file

@ -19,7 +19,7 @@ use WebGUI::Asset;
use WebGUI::VersionTag;
use WebGUI;
use Test::More tests => 55; # increment this value for each test you create
use Test::More tests => 56; # increment this value for each test you create
use Test::Deep;
my $session = WebGUI::Test->session;
@ -287,6 +287,47 @@ $session->setting->set('preventProxyCache', $origPreventProxyCache);
##No accessor
is($session->http->{_http}{cacheControl}, 'none', 'process: HTTP cacheControl set to none to prevent proxying');
####################################################
#
# process
# no duped headBlockContent
#
####################################################
$style->useEmptyStyle(1);
$style->sent(0);
$session->scratch->set('personalStyleId', $templates->{headBlock}->getId);
$styled = $style->process('body.content', 'notATemplateId');
$head = $styled;
$head =~ s/(^HEAD=.+$)/$1/s;
@metas = fetchMultipleMetas($head);
$expectedMetas = [
{
'name' => 'keywords',
'content' => 'keyword1,keyword2'
},
{
'content' => 'WebGUI '.$WebGUI::VERSION,
'name' => 'generator'
},
{
'http-equiv' => 'Content-Type',
'content' => 'text/html; charset=UTF-8'
},
{
'http-equiv' => 'Content-Script-Type',
'content' => 'text/javascript'
},
{
'http-equiv' => 'Content-Style-Type',
'content' => 'text/css'
},
];
cmp_bag(\@metas, $expectedMetas, 'process, headBlock:no duped headBlock from style template');
####################################################
#
# process
@ -298,6 +339,8 @@ is($session->http->{_http}{cacheControl}, 'none', 'process: HTTP cacheControl se
#
####################################################
##Put original template back in place.
$session->scratch->set('personalStyleId', $templates->{personal}->getId);
$style->setPrintableStyleId($templates->{printable}->getId);
is($style->{_printableStyleId}, $templates->{printable}->getId, 'printableStyleId: set');
@ -397,6 +440,17 @@ sub setup_assets {
# '1234567890123456789012'
};
$templates->{personal} = $importNode->addChild($properties, $properties->{id});
$properties = {
title => 'personal style test template with headBlock',
className => 'WebGUI::Asset::Template',
url => 'headblock_style',
namespace => 'Style',
template => 'HEADBLOCK STYLE TEMPLATE\n\nBODY=<tmpl_var body.content>\n\nHEAD=<tmpl_var head.tags>',
headBlock => q|<meta name="keywords" content="keyword1,keyword2" />|,
id => 'testTemplate_headblock',
# '1234567890123456789012'
};
$templates->{headBlock} = $importNode->addChild($properties, $properties->{id});
$properties = {
title => 'personal style test template for printing',
className => 'WebGUI::Asset::Template',