Reverting previous work. Asset->new must return an Asset, even if

no className is passed and the invocant's class is Asset.  This is
due to the root.  In the db, the root Asset has the className WebGUI::Asset,
and the getRoot method matches this.
Changed the failing test in Asset.t to look for a WebGUI::Asset to be returned.
Added two tests to Asset.t to validate the object returned by Asset->getRoot method.
Reverted previous work and updated the POD for Asset->new.
This commit is contained in:
Colin Kuskie 2006-08-08 17:43:44 +00:00
parent c956ba3969
commit 000b2fcce3
3 changed files with 11 additions and 10 deletions

View file

@ -10,9 +10,6 @@
- fix: Redirects get displayed inside page layouts as '0'
- fix: Mysterious "0" Appearing When Admin Is Off
- fix: Deletion of Products
- Fix Asset.pm so that if no className is passed primeval Assets are not
returned.
7.0.4
- Added a forum.lastPost.user.hasRead variable to the Message Board template.

View file

@ -1361,7 +1361,7 @@ sub manageAssetsSearch {
=head2 new ( session, assetId [, className, revisionDate ] )
Constructor. This does not create an asset. Returns a new object if it can, otherwise returns undef.
Constructor. This does not create an asset.
=head3 session
@ -1377,7 +1377,8 @@ By default we'll use whatever class it is called by like WebGUI::Asset::File->ne
=head3 revisionDate
An epoch date that represents a specific version of an asset. By default the most recent version will be used.
An epoch date that represents a specific version of an asset. By default the most recent version will be used. If
no revision date is available it will return undef.
=cut
@ -1406,7 +1407,6 @@ sub new {
}
$class = $className;
}
return undef if $class eq 'WebGUI::Asset';
my $cache = WebGUI::Cache->new($session, ["asset",$assetId,$revisionDate]);
my $properties = $cache->get;
if (exists $properties->{assetId}) {

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use WebGUI::Asset;
use WebGUI::Asset::Wobject::Navigation;
use Test::More tests => 11; # increment this value for each test you create
use Test::More tests => 13; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -47,9 +47,8 @@ $deadAsset = WebGUI::Asset->new($session, '', 'WebGUI::Asset::Wobject::Navigatio
is ($deadAsset, undef,'new constructor with no assetId returns undef');
# -- no class
$deadAsset = 1;
$deadAsset = WebGUI::Asset->new($session, $assetId);
is ($deadAsset, undef,'new constructor with no class returns undef');
my $primevalAsset = WebGUI::Asset->new($session, $assetId);
isa_ok ($primevalAsset, 'WebGUI::Asset');
# Test the newByDynamicClass Constructor
$asset = undef;
@ -70,6 +69,11 @@ $deadAsset = 1;
$deadAsset = WebGUI::Asset->newByDynamicClass($session);
is ($deadAsset, undef, 'newByDynamicClass constructor with no assetId returns undef');
# Root Asset
my $rootAsset = WebGUI::Asset->getRoot($session);
isa_ok($rootAsset, 'WebGUI::Asset');
is($rootAsset->getId, 'PBasset000000000000001', 'Root Asset ID check');
# TODO
# Test the newByPropertiesHashRef Constructor
#