$t->diag('output functions'); $t->is((string) $activeUser, 'John Doe (active_user)', '->__toString() returns the full name and the username'); $t->is($activeUser->getName(), 'John Doe', '->getName() returns the full name of the user'); // group managment $t->diag('group managment'); $t->is($activeUser->getGroupNames(), array(), '->getGroupNames() return empty array if no group is set'); try { $activeUser->addGroupByName('test-group'); $t->fail('->addGroupByName() does throw an exception if group not exist'); } catch (Exception $e) { $t->pass('->addGroupByName() does throw an exception if group not exist'); } $group = new sfGuardGroup(); $group->name = 'test-group'; $group->save(); $t->is($activeUser->hasGroup('test-group'), false, '->hasGroup() return false if user hasn\'t this group'); try { $activeUser->addGroupByName('test-group'); $t->pass('->addGroupByName() does not throw an exception if group exist'); } catch (Exception $e) { $t->diag($e->getMessage()); $t->fail('->addGroupByName() does not throw an exception if group exist'); } $t->is($activeUser->getGroupNames(), array('test-group'), '->getGroupNames() return array with group names'); $t->is($activeUser->hasGroup('test-group'), true, '->hasGroup() return true if user has this group'); // permission managment $t->diag('permission managment'); $t->is($activeUser->getPermissionNames(), array(), '->getPermissionNames() return empty array if no permission is set'); try { $activeUser->addPermissionByName('test-permission'); $t->fail('->addPermissionByName() does throw an exception if group not exist');