Using atkMockSecurityManager: Difference between revisions
Appearance
New page: === Configuring the atkMockDb === Create the testcase using the atkTestCase as its base class, so you can use the setMockDb() method to easily configure your testcases to use the atkMockDb... |
|||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
=== Configuring the | {{howto|advanced|[[Boy Baukema]]}} | ||
Create the testcase using the atkTestCase as its base class, so you can use the | |||
=== Configuring the atkMockSecurityManager === | |||
Create the testcase using the atkTestCase as its base class, so you can use the setMockSecurityManager() method to easily configure your testcases to use the atkMockSecurityManager. | |||
'''Remember to also restore the original database, when you are done with the mock database, or other tests which depend on the regular database may fail!''' | '''Remember to also restore the original database, when you are done with the mock database, or other tests which depend on the regular database may fail!''' | ||
| Line 8: | Line 10: | ||
class test_mynode extends atkTestCase | class test_mynode extends atkTestCase | ||
{ | { | ||
public function test_asimpletestcase() | |||
{ | |||
$secMgr = atknew("atk.security.atkMockSecurityManager"); | |||
$secMgr->m_scheme="group"; | |||
$secMgr->setAllowed(false,'module.node.disallowed_right'); | |||
$secMgr->setAllowed(true, 'module.node.allowed_right'); | |||
$this->setMockSecurityManager($secMgr); | |||
// Some test stuff | |||
$this->restoreSecurityManager(); | |||
} | |||
}</syntaxhighlight> | }</syntaxhighlight> | ||
Latest revision as of 14:06, 12 February 2010
|
ATK Howto: Using atkMockSecurityManager
|
Configuring the atkMockSecurityManager
Create the testcase using the atkTestCase as its base class, so you can use the setMockSecurityManager() method to easily configure your testcases to use the atkMockSecurityManager.
Remember to also restore the original database, when you are done with the mock database, or other tests which depend on the regular database may fail!
require_once(atkconfig("atkroot")."atk/test/class.atktestcase.inc");
class test_mynode extends atkTestCase
{
public function test_asimpletestcase()
{
$secMgr = atknew("atk.security.atkMockSecurityManager");
$secMgr->m_scheme="group";
$secMgr->setAllowed(false,'module.node.disallowed_right');
$secMgr->setAllowed(true, 'module.node.allowed_right');
$this->setMockSecurityManager($secMgr);
// Some test stuff
$this->restoreSecurityManager();
}
}