Jump to content

Using atkMockSecurityManager: Difference between revisions

From NusaATK
No edit summary
Line 1: Line 1:
{{howto|advanced|[[Boy Baukema]]}}
=== Configuring the 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.
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.

Revision as of 17:05, 13 January 2008

ATK Howto: Using atkMockSecurityManager

Complexity: advanced
Author: Boy Baukema

List of other Howto's

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();
  }
}