Adding more test to GroupManager.
This commit is contained in:
parent
d544919ddc
commit
1e3a8aeb89
@ -1,6 +1,6 @@
|
||||
use 5.32.1;
|
||||
|
||||
use Test::Most tests => 5;
|
||||
use Test::Most tests => 9;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -28,11 +28,27 @@ const my $GROUP_MANAGER => BeastBB::DAO::GroupManager->new( app => $APP );
|
||||
my $maybe_group = $GROUP_MANAGER->Get( groupname => 'example_group' );
|
||||
die $maybe_group->ErrorMessage if $maybe_group->IsError;
|
||||
my $group = $maybe_group->Content;
|
||||
ok $group->isa('BeastBB::Model::Group'), 'We can recover groups.';
|
||||
ok $group->isa('BeastBB::Model::Group'),
|
||||
'We can recover groups by groupname.';
|
||||
is_deeply $group->Hash, { groupname => 'example_group', id_group => 1 },
|
||||
'The group hash after groupname recovery is ok.';
|
||||
}
|
||||
|
||||
{
|
||||
$APP->db->Mock(
|
||||
sql =>
|
||||
'SELECT "id_group", "groupname" FROM "group" WHERE "id_group" = ?',
|
||||
results => [ [ 'id_group', 'groupname' ], [ 1, 'example_group' ] ]
|
||||
);
|
||||
my $maybe_group = $GROUP_MANAGER->Get( id_group => 1 );
|
||||
die $maybe_group->ErrorMessage if $maybe_group->IsError;
|
||||
my $group = $maybe_group->Content;
|
||||
ok $group->isa('BeastBB::Model::Group'),
|
||||
'We can recover groups by id_group.';
|
||||
is_deeply $group->Hash, { groupname => 'example_group', id_group => 1 },
|
||||
'The group hash after id_group recovery is ok.';
|
||||
}
|
||||
|
||||
{
|
||||
$APP->db->Mock(
|
||||
sql =>
|
||||
@ -54,7 +70,7 @@ const my $GROUP_MANAGER => BeastBB::DAO::GroupManager->new( app => $APP );
|
||||
);
|
||||
die $maybe_group->ErrorMessage if $maybe_group->IsError;
|
||||
my $group = $maybe_group->Content;
|
||||
ok $group->isa('BeastBB::Model::Group'), 'We can recover groups.';
|
||||
ok $group->isa('BeastBB::Model::Group'), 'We can recover groups with privileges by id_group.';
|
||||
is_deeply $group->Hash,
|
||||
{
|
||||
groupname => 'example_group',
|
||||
@ -63,3 +79,34 @@ const my $GROUP_MANAGER => BeastBB::DAO::GroupManager->new( app => $APP );
|
||||
},
|
||||
'The group hash after groupname recovery is ok.';
|
||||
}
|
||||
|
||||
{
|
||||
$APP->db->Mock(
|
||||
sql =>
|
||||
'SELECT "id_group", "groupname" FROM "group" WHERE "id_group" = ?',
|
||||
results => [ [ 'id_group', 'groupname' ], [ 1, 'example_group' ] ]
|
||||
);
|
||||
$APP->db->Mock(
|
||||
sql =>
|
||||
'SELECT privilege.name FROM group_privilege INNER JOIN privilege USING (id_privilege) WHERE id_group=?',
|
||||
results => [
|
||||
['name'],
|
||||
['example_privilege'],
|
||||
['example_privilege_1']
|
||||
]
|
||||
);
|
||||
my $maybe_group = $GROUP_MANAGER->Get(
|
||||
id_group => 1,
|
||||
recover_privileges => 1
|
||||
);
|
||||
die $maybe_group->ErrorMessage if $maybe_group->IsError;
|
||||
my $group = $maybe_group->Content;
|
||||
ok $group->isa('BeastBB::Model::Group'), 'We can recover groups with privileges by id_group.';
|
||||
is_deeply $group->Hash,
|
||||
{
|
||||
groupname => 'example_group',
|
||||
id_group => 1,
|
||||
privileges => { example_privilege => 1, example_privilege_1 => 1 }
|
||||
},
|
||||
'The group hash after id_group recovery is ok.';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user