template attachments (scripts and stylesheets)
This commit is contained in:
parent
676b124697
commit
f4df3b1280
6 changed files with 664 additions and 36 deletions
|
|
@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use Test::More tests => 15; # increment this value for each test you create
|
||||
use Test::More tests => 32; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
|
@ -67,6 +67,51 @@ my $template3 = $importNode->addChild({
|
|||
ok(!$template3->get('headBlock'), 'headBlock is empty');
|
||||
is($template3->get('extraHeadTags'), 'tag1 tag2 tag3', 'extraHeadTags contains headBlock info');
|
||||
|
||||
my @atts = (
|
||||
{type => 'headScript', sequence => 1, url => 'bar'},
|
||||
{type => 'headScript', sequence => 0, url => 'foo'},
|
||||
{type => 'stylesheet', sequence => 0, url => 'style'},
|
||||
{type => 'bodyScript', sequence => 0, url => 'body'},
|
||||
);
|
||||
|
||||
$template3->addAttachments(\@atts);
|
||||
my $att3 = $template3->getAttachments('headScript');
|
||||
is($att3->[0]->{url}, 'foo', 'has foo');
|
||||
is($att3->[1]->{url}, 'bar', 'has bar');
|
||||
is(@$att3, 2, 'proper size');
|
||||
|
||||
$template3->prepare;
|
||||
ok(exists $session->style->{_link}->{style}, 'style in style');
|
||||
ok(exists $session->style->{_javascript}->{$_}, "$_ in style") for qw(foo bar body);
|
||||
|
||||
# revision-ness of attachments
|
||||
|
||||
# sleep so the revisiondate isn't duplicated
|
||||
sleep 1;
|
||||
|
||||
my $template3rev = $template3->addRevision();
|
||||
my $att4 = $template3rev->getAttachments('headScript');
|
||||
is($att4->[0]->{url}, 'foo', 'rev has foo');
|
||||
is($att4->[1]->{url}, 'bar', 'rev has bar');
|
||||
is(@$att4, 2, 'rev is proper size');
|
||||
|
||||
$template3rev->addAttachments([{type => 'headScript', sequence => 2, url => 'baz'}]);
|
||||
$att4 = $template3rev->getAttachments('headScript');
|
||||
$att3 = $template3->getAttachments('headScript');
|
||||
is($att3->[0]->{url}, 'foo', 'original still has foo');
|
||||
is($att3->[1]->{url}, 'bar', 'original still has bar');
|
||||
is(@$att3, 2, 'original does not have new thing');
|
||||
|
||||
is($att4->[0]->{url}, 'foo', 'rev still has foo');
|
||||
is($att4->[1]->{url}, 'bar', 'rev still has bar');
|
||||
is($att4->[2]->{url}, 'baz', 'rev does have new thing');
|
||||
is(@$att4, 3, 'rev is proper size');
|
||||
|
||||
$template3rev->purgeRevision();
|
||||
|
||||
|
||||
# done checking revision stuff
|
||||
|
||||
$template->purge;
|
||||
$templateCopy->purge;
|
||||
$template3->purge;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue