New AdSpace tests, need to start looking at coverage.

Added some comments and fixed some POD in AdSpace.pm and Ad.pm
This commit is contained in:
Colin Kuskie 2007-02-05 01:01:20 +00:00
parent 870d9dbe46
commit c9726f7b4d
4 changed files with 29 additions and 13 deletions

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use Test::More;
use Test::Deep;
my $numTests = 9; # increment this value for each test you create
my $numTests = 11; # increment this value for each test you create
++$numTests; ##For conditional testing on module load
plan tests => $numTests;
@ -25,7 +25,7 @@ plan tests => $numTests;
my $loaded = use_ok('WebGUI::AdSpace');
my $session = WebGUI::Test->session;
my $adSpace;
my ($adSpace, $alfred, $alfred2, $bruce, $catWoman, $defaultAdSpace );
SKIP: {
@ -41,14 +41,14 @@ SKIP: {
is($data->{name}, $adSpace->get("name"), "get()");
is($data->{adSpaceId}, $adSpace->getId, "getId()");
my $alfred = WebGUI::AdSpace->newByName($session, 'Alfred');
$alfred = WebGUI::AdSpace->newByName($session, 'Alfred');
cmp_deeply($adSpace, $alfred, 'newByName returns identical object if name exists');
my $bruce = WebGUI::AdSpace->newByName($session, 'Bruce');
$bruce = WebGUI::AdSpace->newByName($session, 'Bruce');
is($bruce, undef, 'newByName returns undef if the name does not exist');
my $alfred2 = WebGUI::AdSpace->create($session);
$alfred2 = WebGUI::AdSpace->create($session);
is($alfred2, undef, 'create returns undef unless you pass it a name');
$alfred2 = WebGUI::AdSpace->create($session, {name => 'Alfred'});
@ -58,10 +58,24 @@ SKIP: {
undef $alfred2;
$alfred->set({title => "Alfred's Ad"});
is($alfred->get('title'), "Alfred's Ad", "get, set work on title");
$bruce = WebGUI::AdSpace->create($session, {name => 'Bruce'});
$bruce->set({title => "Bruce's Ad"});
$catWoman = WebGUI::AdSpace->create($session, {name => 'CatWoman'});
$catWoman->set({title => "CatWoman's Ad"});
my $adSpaces = WebGUI::AdSpace->getAdSpaces($session);
cmp_deeply($adSpaces, [$alfred, $bruce, $catWoman], 'getAdSpaces returns all AdSpaces in alphabetical order by title');
}
END {
if (defined $adSpace and ref $adSpace eq 'WebGUI::AdSpace') {
$adSpace->delete;
}
foreach my $ad_space ($adSpace, $bruce, $alfred, $alfred2, $catWoman, $defaultAdSpace ) {
if (defined $ad_space and ref $ad_space eq 'WebGUI::AdSpace') {
$ad_space->delete;
}
}
}