API CHANGE: Added SapphireTest::logInWithPermission() (from r89012)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@89209 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-10-15 22:40:17 +00:00
parent aaeaf6ccb2
commit bc6b3804b6

View File

@ -492,6 +492,39 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
}
}
}
/**
* Create a member and group with the given permission code, and log in with it.
* Returns the member ID.
*/
function logInWithPermssion($permCode = "ADMIN") {
if(!isset($this->cache_generatedMembers[$permCode])) {
$group = new Group();
$group->Title = "$permCode group";
$group->write();
$permission = new Permission();
$permission->Code = $permCode;
$permission->write();
$group->Permissions()->add($permission);
$member = new Member();
$member->FirstName = $permCode;
$member->Surname = "User";
$member->Email = "$permCode@example.org";
$member->write();
$group->Members()->add($member);
$this->cache_generatedMembers[$permCode] = $member;
}
$this->cache_generatedMembers[$permCode]->logIn();
}
/**
* Cache for logInWithPermission()
*/
protected $cache_generatedMembers = array();
}
?>