[Jifty-commit] r4011 - in apps/CASPlus/trunk: t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Aug 29 16:11:47 EDT 2007
Author: sterling
Date: Wed Aug 29 16:11:46 2007
New Revision: 4011
Added:
apps/CASPlus/trunk/t/40-one-to-one_relationships-explicit.t
- copied, changed from r4010, /apps/CASPlus/trunk/t/40-one-to-many_relationships-explicit.t
Modified:
apps/CASPlus/trunk/ (props changed)
Log:
r11070 at riddle: andrew | 2007-08-29 15:11:27 -0500
Added tests for one-to-one relationship role calculations. This test is heavily laden with TODOs since these calculations depend upon back-references which aren't implemented.
Copied: apps/CASPlus/trunk/t/40-one-to-one_relationships-explicit.t (from r4010, /apps/CASPlus/trunk/t/40-one-to-many_relationships-explicit.t)
==============================================================================
--- /apps/CASPlus/trunk/t/40-one-to-many_relationships-explicit.t (original)
+++ apps/CASPlus/trunk/t/40-one-to-one_relationships-explicit.t Wed Aug 29 16:11:46 2007
@@ -32,11 +32,11 @@
$ur_relationship->create(
name => 'user-role',
parent_name => 'my_role',
- child_name => 'my_users',
+ child_name => 'my_user',
relation_parent => $role_profile,
relation_child => $user_profile,
many_parents => 0,
- many_children => 1,
+ many_children => 0,
roles_propagate_to_children => 1,
);
ok($ur_relationship->id, 'created a user-role relationship');
@@ -45,11 +45,11 @@
$uo_relationship->create(
name => 'user-other',
parent_name => 'my_other',
- child_name => 'my_users',
+ child_name => 'my_user',
relation_parent => $other_profile,
relation_child => $user_profile,
many_parents => 0,
- many_children => 1,
+ many_children => 0,
roles_propagate_to_children => 1,
);
ok($ur_relationship->id, 'created a user-other relationship');
@@ -58,11 +58,11 @@
$rr_relationship->create(
name => 'role-role',
parent_name => 'my_parent_role',
- child_name => 'my_child_roles',
+ child_name => 'my_child_role',
relation_parent => $role_profile,
relation_child => $role_profile,
many_parents => 0,
- many_children => 1,
+ many_children => 0,
roles_propagate_to_children => 1,
);
ok($rr_relationship->id, 'created a role-role relationship');
@@ -71,11 +71,11 @@
$or_relationship->create(
name => 'other-role',
parent_name => 'my_role',
- child_name => 'my_others',
+ child_name => 'my_other',
relation_parent => $role_profile,
relation_child => $other_profile,
many_parents => 0,
- many_children => 1,
+ many_children => 0,
roles_propagate_to_children => 1,
);
ok($or_relationship->id, 'created a other-role relationship');
@@ -247,11 +247,10 @@
$user_obj->load(2);
is($user_obj->my_other->id, 1, 'user side of user-2 - first <other> relationship');
- is_deeply(
- [ sort map { $_->id } @{ $other_obj->my_users->items_array_ref } ],
- [ 2 ],
- 'other side of user-2 - first <other> relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($other_obj->my_user->id, 2, 'other side of user-2 - first <other> relationship');
+ };
}
{ # first <other> - role-2 relationship
@@ -269,11 +268,10 @@
$other_obj->load(1);
is($other_obj->my_role->id, 2, 'other side of first <other> - role-2 relationship');
- is_deeply(
- [ sort map { $_->id } @{ $role_obj->my_others->items_array_ref } ],
- [ 1 ],
- 'role side of first <other> - role-2 relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($role_obj->my_other->id, 1, 'role side of first <other> - role-2 relationship');
+ };
}
{ # user-4 - second <other> relationship
@@ -291,11 +289,10 @@
$other_obj->load(2);
is($user_obj->my_other->id, 2, 'user side of user-4 - second <other> relationship');
- is_deeply(
- [ sort map { $_->id } @{ $other_obj->my_users->items_array_ref } ],
- [ 4 ],
- 'other side of user-4 - second <other> relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($other_obj->my_user->id, 4, 'other side of user-4 - second <other> relationship');
+ };
}
{ # role-1 - role-3 relationship
@@ -313,11 +310,10 @@
$child_role_obj->load(1);
is($child_role_obj->my_parent_role->id, 3, 'child side of role-1 - role-3 relationship');
- is_deeply(
- [ sort map { $_->id } @{ $parent_role_obj->my_child_roles->items_array_ref } ],
- [ 1 ],
- 'parent side of role-1 - role-3 relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($parent_role_obj->my_child_role->id, 1, 'parent side of role-3 - role-1 relationship');
+ };
}
{ # user-3 - role-1 relationship
@@ -335,11 +331,10 @@
$role_obj->load(1);
is($user_obj->my_role->id, 1, 'user side of user-3 - role-1 relationship');
- is_deeply(
- [ sort map { $_->id } @{ $role_obj->my_users->items_array_ref } ],
- [ 3 ],
- 'role side of user-3 - role-1 relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($role_obj->my_user->id, 3, 'role side of user-3 - role-1 relationship');
+ };
}
{ # first <other> - role-4 relationship
@@ -357,11 +352,10 @@
$other_obj->load(1);
is($other_obj->my_role->id, 4, 'role side of first <other> - role-4 relationship');
- is_deeply(
- [ sort map { $_->id } @{ $role_obj->my_others->items_array_ref } ],
- [ 1 ],
- 'other side of first <other> - role-4 relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($role_obj->my_other->id, 1, 'other side of first <other> - role-4 relationship');
+ };
}
{ # user-1 - role-1 relationship
@@ -379,11 +373,10 @@
$user_obj->load(1);
is($user_obj->my_role->id, 1, 'user side of user-1 - role-1 relationship');
- is_deeply(
- [ sort map { $_->id } @{ $role_obj->my_users->items_array_ref } ],
- [ 1, 3 ],
- 'role side of user-1 - role-1 relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($role_obj->my_user->id, 1, 'role side of user-1 - role-1 relationship');
+ };
}
{ # user-3 - first <other> relationship
@@ -401,11 +394,10 @@
$other_obj->load(1);
is($user_obj->my_other->id, 1, 'user side of user-3 - first <other> relationship');
- is_deeply(
- [ sort map { $_->id } @{ $other_obj->my_users->items_array_ref } ],
- [ 2, 3 ],
- 'other side of user-3 - first <other> relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($other_obj->my_user->id, 3, 'other side of user-3 - first <other> relationship');
+ };
}
{ # role-1 - role-2 relationship
@@ -423,11 +415,10 @@
$child_role_obj->load(1);
is($child_role_obj->my_parent_role->id, 2, 'child side of role-1 - role-2 relationship');
- is_deeply(
- [ sort map { $_->id } @{ $parent_role_obj->my_child_roles->items_array_ref } ],
- [ 1 ],
- 'parent side of role-1 - role-2 relationship'
- );
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($parent_role_obj->my_child_role->id, 1, 'parent side of role-1 - role-2 relationship');
+ };
}
# Create the permissions
@@ -556,12 +547,12 @@
perms => [ 1, 2, 3, 4 ],
},
2 => {
- roles => [ 4 ],
- perms => [ 8, 9, 10 ],
+ roles => [ ],
+ perms => [ ],
},
3 => {
- roles => [ 1, 2, 4 ],
- perms => [ 1, 2, 3, 4, 8, 9, 10 ],
+ roles => [ 4 ],
+ perms => [ 8, 9, 10 ],
},
4 => {
roles => [ ],
@@ -571,27 +562,20 @@
my %role_members = (
'' => [
- ':5:@2:4:',
':10:@2:6:',
':4:@4:9:',
':8:@2:4:',
':2:@3:3:',
],
1 => [ ],
- 2 => [
- ':8:@1:2:',
- ],
+ 2 => [ ],
3 => [ ],
- 4 => [
- ':5:@2:4:@4:9:',
- ],
+ 4 => [ ],
5 => [
':1:@1:2:',
],
6 => [ ],
- 7 => [
- ':8:@1:2:@3:3:',
- ],
+ 7 => [ ],
8 => [
':8:@2:4:@4:9:',
],
@@ -607,7 +591,10 @@
my $cache_paths = CASPlus::Model::RoleMemberPathCacheCollection->new(current_user => $system_user);
$cache_paths->unlimit;
-is($cache_paths->count_all, (sum map { scalar @$_ } values %role_members), 'there are the right number of cache paths');
+TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($cache_paths->count_all, (sum map { scalar @$_ } values %role_members), 'there are the right number of cache paths');
+};
#while (my $path_cache = $cache_paths->next) {
# diag($path_cache->cache_path);
@@ -629,7 +616,10 @@
$cache_paths = CASPlus::Model::RoleMemberPathCacheCollection->new(current_user => $system_user);
$cache_paths->unlimit;
- is($cache_paths->count_all, (sum map { scalar @$_ } values %role_members), 'there are the right number of cache paths');
+ TODO: {
+ local $TODO = 'Jifty::DBI does not support one-to-one back references yet.';
+ is($cache_paths->count_all, (sum map { scalar @$_ } values %role_members), 'there are the right number of cache paths');
+ };
}
}
More information about the Jifty-commit
mailing list