added tests for packed templates
This commit is contained in:
parent
b7bd11acb5
commit
939ad5a4bf
1 changed files with 74 additions and 0 deletions
74
t/Asset/Template/packed.t
Normal file
74
t/Asset/Template/packed.t
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
# vim:syntax=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
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Make sure the packed version of the default WebGUI templates works
|
||||
# as it's supposed to
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use HTML::Packer;
|
||||
use CSS::Packer;
|
||||
use JavaScript::Packer;
|
||||
use WebGUI::Asset::Template;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $templates = WebGUI::Asset->getRoot( $session )
|
||||
->getLineage( ['descendants'], {
|
||||
includeOnlyClasses => [ 'WebGUI::Asset::Template' ],
|
||||
} );
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => @$templates * 4; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test every template to make sure packed doesn't cause ERROR
|
||||
for my $templateId ( @$templates ) {
|
||||
my $template = WebGUI::Asset::Template->new( $session, $templateId );
|
||||
|
||||
# Add a new revision to prevent changing anything
|
||||
$template = $template->addRevision;
|
||||
|
||||
# Make sure packed version is created
|
||||
$template->update({ template => $template->get('template') . " <p>HOPE IS THE BEST OF THINGS</p>" });
|
||||
ok( $template->get('templatePacked'), "Packed template $templateId contains something" );
|
||||
like( $template->get('templatePacked'), qr{<p>HOPE IS THE BEST OF THINGS</p>$}, "Packed template $templateId actually packed" );
|
||||
|
||||
# Make sure packed version is used
|
||||
$template->update({ usePacked => 1 });
|
||||
|
||||
# Does it even work?
|
||||
my $content = $template->process;
|
||||
ok( $content, "Packed template $templateId gives back SOMETHING" )
|
||||
or diag( "URL: " . $template->getUrl . "\nPACKED: " . $template->get('templatePacked') );
|
||||
unlike( $content, qr/^ERROR/, "Packed template $templateId does not throw error" )
|
||||
or diag( "URL: " . $template->getUrl );
|
||||
|
||||
# Cleanup
|
||||
$template->purgeRevision;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
WebGUI::VersionTag->getWorking( $session )->rollback;
|
||||
}
|
||||
#vim:ft=perl
|
||||
Loading…
Add table
Add a link
Reference in a new issue