Skip to content

Commit

Permalink
Updating test method names and moving parameter modification around.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 24, 2010
1 parent e111735 commit 35ec5ce
Showing 1 changed file with 25 additions and 49 deletions.
74 changes: 25 additions & 49 deletions cake/tests/cases/libs/controller/components/acl.test.php
Expand Up @@ -174,48 +174,31 @@ class DbAclTwoTest extends DbAcl {
* @return void
*/
function __construct() {
$this->Aro =& new AroTwoTest();
$this->Aro->Permission =& new PermissionTwoTest();
$this->Aco =& new AcoTwoTest();
$this->Aro->Permission =& new PermissionTwoTest();
$this->Aro = new AroTwoTest();
$this->Aro->Permission = new PermissionTwoTest();
$this->Aco = new AcoTwoTest();
$this->Aro->Permission = new PermissionTwoTest();
}
}

Mock::generate('AclInterface', 'MockAclImplementation');

/**
* Short description for class.
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AclComponentTest extends CakeTestCase {
/**
* fixtures property
*
* @var array
* @access public
*/
public $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two');
/**
* startTest method
*
* @access public
* @return void
*/
function startTest() {
$this->Acl =& new AclComponent();
}

/**
* before method
*
* @param mixed $method
* @access public
* @return void
*/
function before($method) {
Configure::write('Acl.classname', 'DbAclTwoTest');
Configure::write('Acl.database', 'test_suite');
parent::before($method);
Configure::write('Acl.classname', 'MockAclImplementation');
$this->Acl = new AclComponent();
}

/**
Expand Down Expand Up @@ -246,7 +229,8 @@ function testConstrutorException() {
* @return void
*/
function testAdapter() {
$implementation = new IniAcl();
$implementation = new MockAclImplementation();
$implementation->expectOnce('initialize', array($this->Acl));
$this->assertNull($this->Acl->adapter($implementation));

$this->assertEqual($this->Acl->adapter(), $implementation, 'Returned object is different %s');
Expand Down Expand Up @@ -288,7 +272,7 @@ class IniAclTestCase extends CakeTestCase {
* @access public
* @return void
*/
function testIniReadConfigFile() {
function testReadConfigFile() {
$Ini = new IniAcl();
$iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';
$result = $Ini->readConfigFile($iniFile);
Expand Down Expand Up @@ -335,7 +319,7 @@ function testIniReadConfigFile() {
* @access public
* @return void
*/
function testIniCheck() {
function testCheck() {
$iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';

$Ini = new IniAcl();
Expand Down Expand Up @@ -376,20 +360,11 @@ class DbAclTestCase extends CakeTestCase {
* @return void
*/
function startTest() {
$this->Acl =& new AclComponent();
}
$this->_settings = Configure::read('Acl');

/**
* before method
*
* @param mixed $method
* @access public
* @return void
*/
function before($method) {
Configure::write('Acl.classname', 'DbAclTwoTest');
Configure::write('Acl.database', 'test_suite');
parent::before($method);
$this->Acl = new AclComponent();
}

/**
Expand All @@ -398,8 +373,9 @@ function before($method) {
* @access public
* @return void
*/
function tearDown() {
function endTest() {
unset($this->Acl);
Configure::write('Acl', $this->_settings);
}

/**
Expand All @@ -408,7 +384,7 @@ function tearDown() {
* @access public
* @return void
*/
function testAclCreate() {
function testCreate() {
$this->Acl->Aro->create(array('alias' => 'Chotchkey'));
$this->assertTrue($this->Acl->Aro->save());

Expand Down Expand Up @@ -436,7 +412,7 @@ function testAclCreate() {
* @access public
* @return void
*/
function testAclCreateWithParent() {
function testCreateWithParent() {
$parent = $this->Acl->Aro->findByAlias('Peter', null, null, -1);
$this->Acl->Aro->create();
$this->Acl->Aro->save(array(
Expand All @@ -456,7 +432,7 @@ function testAclCreateWithParent() {
* @access public
* @return void
*/
function testDbAclAllow() {
function testAllow() {
$this->assertFalse($this->Acl->check('Micheal', 'tpsReports', 'read'));
$this->assertTrue($this->Acl->allow('Micheal', 'tpsReports', array('read', 'delete', 'update')));
$this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'update'));
Expand Down Expand Up @@ -497,7 +473,7 @@ function testDbAclAllow() {
* @access public
* @return void
*/
function testDbAclCheck() {
function testCheck() {
$this->assertTrue($this->Acl->check('Samir', 'print', 'read'));
$this->assertTrue($this->Acl->check('Lumbergh', 'current', 'read'));
$this->assertFalse($this->Acl->check('Milton', 'smash', 'read'));
Expand Down Expand Up @@ -530,7 +506,7 @@ function testDbAclCheck() {
* @access public
* @return void
*/
function testDbAclCascadingDeny() {
function testAclCascadingDeny() {
$this->Acl->inherit('Bobs', 'ROOT', '*');
$this->assertTrue($this->Acl->check('admin', 'tpsReports', 'delete'));
$this->assertTrue($this->Acl->check('Bobs', 'tpsReports', 'delete'));
Expand All @@ -545,7 +521,7 @@ function testDbAclCascadingDeny() {
* @access public
* @return void
*/
function testDbAclDeny() {
function testDeny() {
$this->assertTrue($this->Acl->check('Micheal', 'smash', 'delete'));
$this->Acl->deny('Micheal', 'smash', 'delete');
$this->assertFalse($this->Acl->check('Micheal', 'smash', 'delete'));
Expand Down Expand Up @@ -600,7 +576,7 @@ function testAclNodeLookup() {
* @access public
* @return void
*/
function testDbInherit() {
function testInherit() {
//parent doesn't have access inherit should still deny
$this->assertFalse($this->Acl->check('Milton', 'smash', 'delete'));
$this->Acl->inherit('Milton', 'smash', 'delete');
Expand All @@ -618,7 +594,7 @@ function testDbInherit() {
* @access public
* @return void
*/
function testDbGrant() {
function testGrant() {
$this->assertFalse($this->Acl->check('Samir', 'tpsReports', 'create'));
$this->Acl->allow('Samir', 'tpsReports', 'create');
$this->assertTrue($this->Acl->check('Samir', 'tpsReports', 'create'));
Expand All @@ -640,7 +616,7 @@ function testDbGrant() {
* @access public
* @return void
*/
function testDbRevoke() {
function testRevoke() {
$this->assertTrue($this->Acl->check('Bobs', 'tpsReports', 'read'));
$this->Acl->deny('Bobs', 'tpsReports', 'read');
$this->assertFalse($this->Acl->check('Bobs', 'tpsReports', 'read'));
Expand Down

0 comments on commit 35ec5ce

Please sign in to comment.