mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
aaeaf6ccb2
commit
bc6b3804b6
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user