Move get_tables from Meta/Class into Meta/Asset. s/getTables/meta->get_tables/;

This commit is contained in:
Colin Kuskie 2010-01-04 15:34:24 -08:00
parent b72e3a1cd1
commit ce3edcf743
8 changed files with 74 additions and 38 deletions

View file

@ -20,13 +20,13 @@ use Test::More;
use Test::Deep;
use Test::Exception;
plan tests => 26;
plan tests => 29;
my $session = WebGUI::Test->session;
{
note "session and title";
note "new, session and title";
my $asset = WebGUI::Asset->new({session => $session, });
isa_ok $asset, 'WebGUI::Asset';
@ -102,6 +102,24 @@ my $session = WebGUI::Test->session;
isa_ok $asset, 'WebGUI::Asset::Snippet';
}
{
note "Property inspection";
my $asset = WebGUI::Asset->new({
session => $session,
});
cmp_deeply(
[$asset->meta->get_all_properties],
array_each(
methods(
tableName => 'assetData',
)
),
'all properties have the right tableName'
);
}
{
note "getClassById";
my $class;
@ -114,3 +132,11 @@ my $session = WebGUI::Test->session;
$class = WebGUI::Asset->getClassById($session, 'noIdHereBoss');
is $class, undef, '... returns undef if the class cannot be found';
}
{
note "new, fetching from db";
my $asset;
$asset = WebGUI::Asset->new($session, 'PBasset000000000000001');
isa_ok $asset, 'WebGUI::Asset';
is $asset->title, 'Root', 'got the right asset';
}

View file

@ -128,6 +128,12 @@ use WebGUI::Test;
my $object2 = __PACKAGE__->new(tableName => 'notAsset');
::is $object2->tableName, 'asset', 'tableName ignored in constructor';
::cmp_deeply(
[ __PACKAGE__->meta->get_tables ],
[qw/asset/],
'get_tables works for a simple asset'
);
}
{
@ -188,6 +194,18 @@ use WebGUI::Test;
'checking inheritance of properties by name, insertion order'
);
::cmp_deeply(
[ WGT::Class::AlsoAsset->meta->get_tables ],
[qw/asset/],
'get_tables: checking inheritance'
);
::cmp_deeply(
[ WGT::Class::Asset::Snippet->meta->get_tables ],
[qw/asset snippet/],
'get_tables: checking inheritance on subclass'
);
}
{
@ -214,10 +232,4 @@ use WebGUI::Test;
'checking inheritance of properties by name, insertion order with an overridden property'
);
cmp_deeply(
[WGT::Class::Asset::NotherOne->meta->get_tables],
[qw/asset snippet/],
'get_tables returns both tables'
);
}