more tests for AdSpace and added more POD to AdSpace.pm and Ad.pm

This commit is contained in:
Colin Kuskie 2007-02-04 04:12:19 +00:00
parent 7323ec0c0a
commit 870d9dbe46
3 changed files with 29 additions and 8 deletions

View file

@ -60,6 +60,8 @@ sub countClick {
=head2 create ( session, properties )
Object constructor for new AdSpaces.
=head3 session
A reference to the current session.
@ -73,7 +75,7 @@ The properties used to create this object. See the set() method for details.
sub create {
my $class = shift;
my $session = shift;
my $properties = shift;
my $properties = shift || {};
return undef unless $properties->{name};
my $test = $class->newByName($session, $properties->{name});
return undef if defined $test;
@ -163,7 +165,7 @@ sub get {
=head2 getAds ( )
Returns an array reference containing all the ad objects in this ad space.
Returns an array reference containing all the ads this ad space as objects.
=cut
@ -181,7 +183,7 @@ sub getAds {
=head2 getAdSpaces ( session )
Returns an array reference containing all the ad spaces. This is a class method.
Returns an array reference containing all the ad spaces as objects. This is a class method.
=cut
@ -213,7 +215,7 @@ sub getId {
=head2 new ( session, id )
Constructor.
Object constructor for fetching an existing AdSpace by id.
=head3 session
@ -238,7 +240,7 @@ sub new {
=head2 newByName ( session, name )
Constructor.
Object constructor for fetching an existing AdSpace by name.
=head3 session

View file

@ -42,6 +42,8 @@ These methods are available from this class:
=head2 create ( session, adSpaceId, properties )
Object constructor for new Ads.
=head3 session
A reference to the current session
@ -133,7 +135,7 @@ sub getId {
=head2 new ( session, id )
Constructor.
Object constructor for fetching an existing Ad.
=head3 session

View file

@ -14,10 +14,10 @@ use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
#use Test::More tests => 3;
use Test::More;
use Test::Deep;
my $numTests = 4; # increment this value for each test you create
my $numTests = 9; # increment this value for each test you create
++$numTests; ##For conditional testing on module load
plan tests => $numTests;
@ -41,6 +41,23 @@ SKIP: {
is($data->{name}, $adSpace->get("name"), "get()");
is($data->{adSpaceId}, $adSpace->getId, "getId()");
my $alfred = WebGUI::AdSpace->newByName($session, 'Alfred');
cmp_deeply($adSpace, $alfred, 'newByName returns identical object if name exists');
my $bruce = WebGUI::AdSpace->newByName($session, 'Bruce');
is($bruce, undef, 'newByName returns undef if the name does not exist');
my $alfred2 = WebGUI::AdSpace->create($session);
is($alfred2, undef, 'create returns undef unless you pass it a name');
$alfred2 = WebGUI::AdSpace->create($session, {name => 'Alfred'});
is($alfred2, undef, 'create returns undef if the name already exists');
isa_ok($alfred->session, 'WebGUI::Session');
undef $alfred2;
}
END {