more Ad tests, testing for rendering text ads

This commit is contained in:
Colin Kuskie 2007-02-13 23:12:51 +00:00
parent 5892ad8721
commit 52a3023b09

View file

@ -17,6 +17,7 @@ use WebGUI::AdSpace;
use Test::More;
use Test::Deep;
use HTML::TokeParser;
my $newAdSettings = {
title => "Untitled",
@ -35,7 +36,7 @@ my $newAdSettings = {
priority => "0",
};
my $numTests = 7; # increment this value for each test you create
my $numTests = 13; # increment this value for each test you create
$numTests += scalar keys %{ $newAdSettings };
++$numTests; ##For conditional testing on module load
@ -45,7 +46,7 @@ my $loaded = use_ok('WebGUI::AdSpace::Ad');
my $session = WebGUI::Test->session;
my $ad;
my $richAd;
my ($richAd, $textAd);
my $adSpace;
SKIP: {
@ -83,10 +84,47 @@ SKIP: {
my $userName = $session->user->username;
like($renderedAd, qr/This is rich, $userName/, 'Rich media ads render macros');
##In this series of tests, we'll render a text ad and then pick it apart and make
##sure that all th requisite components are in there.
$adSpace->set({
width => 102,
height => 202
});
$textAd = WebGUI::AdSpace::Ad->create($session, $adSpace->getId);
$textAd->set({
type => 'text',
borderColor => 'black',
backgroundColor => 'white',
textColor => 'blue',
title => 'This is a text ad',
adText => 'Will hack for Gooey dolls.',
});
my $renderedTextAd = $textAd->get('renderedAd');
my $textP = HTML::TokeParser->new(\$renderedTextAd);
##Outer div checks
my $token = $textP->get_tag("div");
my $style = $token->[1]{style};
like($style, qr/height:200/, 'adSpace height rendered correctly');
like($style, qr/width:100/, 'adSpace width rendered correctly');
like($style, qr/border:solid black/, 'ad borderColor rendered correctly');
##Link checks
$token = $textP->get_tag("a");
my $href = $token->[1]{href};
like($href, qr/op=clickAd/, 'ad link has correct operation');
my $adId = $textAd->getId;
like($href, qr/id=$adId/, 'ad link has correct ad id');
$style = $token->[1]{style};
like($style, qr/background-color:white/, 'ad link background is white');
}
END {
foreach my $advertisement ($ad, $richAd) {
foreach my $advertisement ($ad, $richAd, $textAd) {
if (defined $advertisement and ref $advertisement eq 'WebGUI::AdSpace::Ad') {
$advertisement->delete;
}