mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Updated tests on DB_ACL coverage up to 88%
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6998 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2558705e14
commit
1523020ea1
2 changed files with 60 additions and 5 deletions
|
@ -33,7 +33,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|||
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
* DB ACL wrapper test class
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
|
@ -44,7 +44,7 @@ class DbAclNodeTestBase extends AclNode {
|
|||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
* Aro Test Wrapper
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
|
@ -56,7 +56,7 @@ class DbAroTest extends DbAclNodeTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
* Aco Test Wrapper
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
|
@ -68,7 +68,7 @@ class DbAcoTest extends DbAclNodeTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
* Permission Test Wrapper
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
|
@ -90,6 +90,25 @@ class DbAcoActionTest extends CakeTestModel {
|
|||
var $useTable = 'aco_actions';
|
||||
var $belongsTo = array('DbAcoTest' => array('foreignKey' => 'aco_id'));
|
||||
}
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
*/
|
||||
class DbAroUserTest extends CakeTestModel {
|
||||
var $name = 'AuthUser';
|
||||
var $useTable = 'auth_users';
|
||||
|
||||
function bindNode($ref = null) {
|
||||
if (Configure::read('DbAclbindMode') == 'string') {
|
||||
return 'ROOT/admins/Gandalf';
|
||||
} elseif (Configure::read('DbAclbindMode') == 'array') {
|
||||
return array('DbAroTest' => array('DbAroTest.model' => 'AuthUser', 'DbAroTest.foreign_key' => 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description for class.
|
||||
*
|
||||
|
@ -113,7 +132,7 @@ class DBACL_TEST extends DB_ACL {
|
|||
*/
|
||||
class AclNodeTest extends CakeTestCase {
|
||||
|
||||
var $fixtures = array('core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action');
|
||||
var $fixtures = array('core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action', 'core.auth_user');
|
||||
|
||||
function setUp() {
|
||||
Configure::write('Acl.classname', 'DB_ACL_TEST');
|
||||
|
@ -151,6 +170,37 @@ class AclNodeTest extends CakeTestCase {
|
|||
|
||||
$result = Set::extract($Aco->node('Controller2/action3/record5'), '{n}.DbAcoTest.id');
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $Aco->node('');
|
||||
$this->assertEqual($result, null);
|
||||
}
|
||||
|
||||
function testNodeArrayFind() {
|
||||
$Aro = new DbAroTest();
|
||||
Configure::write('DbAclbindMode', 'string');
|
||||
$result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => '1', 'foreign_key' => '1'))), '{n}.DbAroTest.id');
|
||||
$expected = array(3, 2, 1);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
Configure::write('DbAclbindMode', 'array');
|
||||
$result = Set::extract($Aro->node(array('DbAroUserTest' => array('id' => 4, 'foreign_key' => 2))), '{n}.DbAroTest.id');
|
||||
$expected = array(4);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function testNodeObjectFind() {
|
||||
$Aro = new DbAroTest();
|
||||
$Model = new DbAroUserTest();
|
||||
$Model->id = 1;
|
||||
$result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
|
||||
$expected = array(3, 2, 1);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$Model->id = 2;
|
||||
$result = Set::extract($Aro->node($Model), '{n}.DbAroTest.id');
|
||||
$expected = array(4, 2, 1);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
}
|
||||
|
||||
function testNodeAliasParenting() {
|
||||
|
|
5
cake/tests/fixtures/aro_fixture.php
vendored
5
cake/tests/fixtures/aro_fixture.php
vendored
|
@ -46,6 +46,11 @@ class AroFixture extends CakeTestFixture {
|
|||
);
|
||||
|
||||
var $records = array(
|
||||
array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT', 'lft' => 1, 'rght' => 8),
|
||||
array('id' => '2', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => '1', 'alias' => 'admins', 'lft' => 2, 'rght' => 7),
|
||||
array('id' => '3', 'parent_id' => '2', 'model' => 'AuthUser', 'foreign_key' => '1', 'alias' => 'Gandalf', 'lft' => 3, 'rght' => 4),
|
||||
array('id' => '4', 'parent_id' => '2', 'model' => 'AuthUser', 'foreign_key' => '2', 'alias' => 'Elrond', 'lft' => 5, 'rght' => 6),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue