getClassById encapculates getting a className from the database, indexed by assetId.

Also, work on newById, newByUrl.
This commit is contained in:
Colin Kuskie 2010-01-04 11:33:09 -08:00
parent fde81306c6
commit b72e3a1cd1
2 changed files with 72 additions and 31 deletions

View file

@ -20,12 +20,13 @@ use Test::More;
use Test::Deep;
use Test::Exception;
plan tests => 22;
plan tests => 26;
my $session = WebGUI::Test->session;
{
note "session and title";
my $asset = WebGUI::Asset->new({session => $session, });
isa_ok $asset, 'WebGUI::Asset';
@ -55,6 +56,7 @@ my $session = WebGUI::Test->session;
{
note "menuTitle";
my $asset = WebGUI::Asset->new({
session => $session,
title => 'asset title',
@ -82,6 +84,7 @@ my $session = WebGUI::Test->session;
}
{
note "Class dispatch";
my $asset = WebGUI::Asset->new({
session => $session,
title => 'testing snippet',
@ -98,3 +101,16 @@ my $session = WebGUI::Test->session;
isa_ok $asset, 'WebGUI::Asset::Snippet';
}
{
note "getClassById";
my $class;
$class = WebGUI::Asset->getClassById($session, 'PBasset000000000000001');
is $class, 'WebGUI::Asset', 'getClassById: retrieve a class';
$class = WebGUI::Asset->getClassById($session, 'PBasset000000000000001');
is $class, 'WebGUI::Asset', '... cache check';
$class = WebGUI::Asset->getClassById($session, 'PBasset000000000000002');
is $class, 'WebGUI::Asset::Wobject::Folder', '... retrieve another class';
$class = WebGUI::Asset->getClassById($session, 'noIdHereBoss');
is $class, undef, '... returns undef if the class cannot be found';
}