This set of tests brings overall coverage close to 100% for the Ad module.
Remainnig conditionals in the set subroutine will be tested after 7.4 comes our and ->get can be modified to return the whole set of properties. Fixed a bug in the Ad module where the priority could not be set to 0.
This commit is contained in:
parent
859886e8f8
commit
9666dadc82
2 changed files with 20 additions and 4 deletions
|
|
@ -253,7 +253,7 @@ sub set {
|
|||
$self->{_properties}{borderColor} = $properties->{borderColor} || $self->{_properties}{borderColor} || "#000000";
|
||||
$self->{_properties}{textColor} = $properties->{textColor} || $self->{_properties}{textColor} || "#000000";
|
||||
$self->{_properties}{backgroundColor} = $properties->{backgroundColor} || $self->{_properties}{backgroundColor} || "#ffffff";
|
||||
$self->{_properties}{priority} = $properties->{priority} || $self->{_properties}{priority} || "0";
|
||||
$self->{_properties}{priority} = exists $properties->{priority} ? $properties->{priority} : $self->{_properties}{priority};
|
||||
# prerender the ad for faster display
|
||||
my $adSpace = WebGUI::AdSpace->new($self->session, $self->get("adSpaceId"));
|
||||
if ($self->get("type") eq "text") {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ my $newAdSettings = {
|
|||
priority => "0",
|
||||
};
|
||||
|
||||
my $numTests = 23; # increment this value for each test you create
|
||||
my $numTests = 28; # increment this value for each test you create
|
||||
$numTests += scalar keys %{ $newAdSettings };
|
||||
++$numTests; ##For conditional testing on module load
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ my $loaded = use_ok('WebGUI::AdSpace::Ad');
|
|||
|
||||
my $session = WebGUI::Test->session;
|
||||
my $ad;
|
||||
my ($richAd, $textAd, $imageAd, $nonAd);
|
||||
my ($richAd, $textAd, $imageAd, $nonAd, $setAd);
|
||||
my $adSpace;
|
||||
my $imageStorage = WebGUI::Storage::Image->create($session);
|
||||
$imageStorage->addFileFromScalar('foo.bmp', 'This is not really an image');
|
||||
|
|
@ -180,10 +180,26 @@ SKIP: {
|
|||
|
||||
is($renderedNonAd, undef, 'undefined ad types are not rendered');
|
||||
|
||||
$nonAd->delete;
|
||||
|
||||
$nonAd = WebGUI::AdSpace::Ad->new($session, 'nonExistantId');
|
||||
is($nonAd, undef, 'requesting a non-existant id via new returns undef');
|
||||
|
||||
my $setAd = WebGUI::AdSpace::Ad->create($session, $adSpace->getId, {isActive => 1});
|
||||
is($setAd->get('isActive'), 1, 'set isActive true during instantiation');
|
||||
$setAd->set({isActive=>0});
|
||||
is($setAd->get('isActive'), 0, 'set isActive false during instantiation');
|
||||
$setAd->delete;
|
||||
|
||||
my $setAd = WebGUI::AdSpace::Ad->create($session, $adSpace->getId, {priority => 1});
|
||||
is($setAd->get('priority'), 1, 'set priority=1 during instantiation');
|
||||
$setAd->set({priority=>0});
|
||||
is($setAd->get('priority'), 0, 'set priority=0');
|
||||
|
||||
}
|
||||
|
||||
END {
|
||||
foreach my $advertisement ($ad, $richAd, $textAd, $imageAd, $nonAd) {
|
||||
foreach my $advertisement ($ad, $richAd, $textAd, $imageAd, $nonAd, $setAd) {
|
||||
if (defined $advertisement and ref $advertisement eq 'WebGUI::AdSpace::Ad') {
|
||||
$advertisement->delete;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue