mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Added SapphireTest::logInWithPermission() (merged from r89209)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@91034 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
15f1905889
commit
4443df7b0a
@ -249,6 +249,39 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
return $dbname;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user