diff --git a/lib/WebGUI/AdSpace/Ad.pm b/lib/WebGUI/AdSpace/Ad.pm
index 0cba9636a..353aa5d1f 100644
--- a/lib/WebGUI/AdSpace/Ad.pm
+++ b/lib/WebGUI/AdSpace/Ad.pm
@@ -260,7 +260,7 @@ sub set {
$self->{_properties}{renderedAd} = '
';
} elsif ($self->get("type") eq "image") {
my $storage = WebGUI::Storage::Image->get($self->session, $self->get("storageId"));
- $self->{_properties}{renderedAd} = '';
+ $self->{_properties}{renderedAd} = '';
} elsif ($self->get("type") eq "rich") {
my $ad = $self->get("richMedia");
WebGUI::Macro::process($self->session, \$ad);
diff --git a/t/AdSpace/Ad.t b/t/AdSpace/Ad.t
index 77b8a42eb..dda901ddf 100644
--- a/t/AdSpace/Ad.t
+++ b/t/AdSpace/Ad.t
@@ -36,7 +36,7 @@ my $newAdSettings = {
priority => "0",
};
-my $numTests = 13; # increment this value for each test you create
+my $numTests = 22; # increment this value for each test you create
$numTests += scalar keys %{ $newAdSettings };
++$numTests; ##For conditional testing on module load
@@ -46,8 +46,10 @@ my $loaded = use_ok('WebGUI::AdSpace::Ad');
my $session = WebGUI::Test->session;
my $ad;
-my ($richAd, $textAd);
+my ($richAd, $textAd, $imageAd);
my $adSpace;
+my $imageStorage = WebGUI::Storage::Image->create($session);
+$imageStorage->addFileFromScalar('foo.bmp', 'This is not really an image');
SKIP: {
@@ -121,10 +123,58 @@ SKIP: {
$style = $token->[1]{style};
like($style, qr/background-color:white/, 'ad link background is white');
+
+ $token = $textP->get_tag("span");
+ $style = $token->[1]{style};
+ like($style, qr/color:blue/, 'ad title text foreground is blue');
+
+ $token = $textP->get_tag("span");
+ $style = $token->[1]{style};
+ like($style, qr/color:blue/, 'ad title text foreground is blue');
+
+ my $adText = $textP->get_trimmed_text('/span');
+ is($adText, $textAd->get('adText'), 'ad text is correct');
+
+ ##Ditto for the image ad
+ $adSpace->set({
+ width => 250,
+ height => 250
+ });
+
+ $imageAd = WebGUI::AdSpace::Ad->create($session, $adSpace->getId);
+ $imageAd->set({
+ type => 'image',
+ title => 'This is an image ad',
+ storageId => $imageStorage->getId,
+ });
+ my $renderedImageAd = $imageAd->get('renderedAd');
+
+ my $textP = HTML::TokeParser->new(\$renderedImageAd);
+
+ ##Outer div checks
+ my $token = $textP->get_tag("div");
+ my $style = $token->[1]{style};
+ like($style, qr/height:250/, 'adSpace height rendered correctly, image');
+ like($style, qr/width:250/, 'adSpace width rendered correctly, image');
+
+ ##Link checks
+ $token = $textP->get_tag("a");
+ my $href = $token->[1]{href};
+ like($href, qr/op=clickAd/, 'ad link has correct operation, image');
+
+ $adId = $imageAd->getId;
+ like($href, qr/id=$adId/, 'ad link has correct ad id, image');
+
+ $token = $textP->get_tag("img");
+ $style = $token->[1]{src};
+ is($style, $imageStorage->getUrl($imageStorage->getFiles->[0]), 'ad image points at correct file');
+ $style = $token->[1]{alt};
+ is($style, $imageAd->get('title'), 'ad title matches, image');
+
}
END {
- foreach my $advertisement ($ad, $richAd, $textAd) {
+ foreach my $advertisement ($ad, $richAd, $textAd, $imageAd) {
if (defined $advertisement and ref $advertisement eq 'WebGUI::AdSpace::Ad') {
$advertisement->delete;
}
@@ -132,4 +182,7 @@ END {
if (defined $adSpace and ref $adSpace eq 'WebGUI::AdSpace') {
$adSpace->delete;
}
+ if (defined $imageStorage and ref $imageStorage eq 'WebGUI::Storage::Image') {
+ $imageStorage->delete;
+ }
}