Skip to content

Commit

Permalink
Merge branch '2.1' into 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 13, 2012
2 parents a495216 + a2fb417 commit 5687d97
Show file tree
Hide file tree
Showing 30 changed files with 208 additions and 144 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Component.php
Expand Up @@ -120,8 +120,8 @@ public function startup(Controller $controller) {
}

/**
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
* Controller::render()
* Called before the Controller::beforeRender(), and before
* the view class is loaded, and before Controller::render()
*
* @param Controller $controller Controller with components to beforeRender
* @return void
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/CakeSchema.php
Expand Up @@ -484,7 +484,7 @@ public function compare($old, $new = null) {
if (!empty($old[$table][$field])) {
$diff = $this->_arrayDiffAssoc($value, $old[$table][$field]);
if (!empty($diff) && $field !== 'indexes' && $field !== 'tableParameters') {
$tables[$table]['change'][$field] = array_merge($old[$table][$field], $diff);
$tables[$table]['change'][$field] = $value;
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -297,7 +297,8 @@ public function getCharsetName($name) {
* @throws CakeException
*/
public function describe($model) {
$cache = parent::describe($model);
$key = $this->fullTableName($model, false);
$cache = parent::describe($key);
if ($cache != null) {
return $cache;
}
Expand Down Expand Up @@ -331,7 +332,7 @@ public function describe($model) {
}
}
}
$this->_cacheDescription($this->fullTableName($model, false), $fields);
$this->_cacheDescription($key, $fields);
$cols->closeCursor();
return $fields;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -186,8 +186,8 @@ public function listSources($data = null) {
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
$fields = parent::describe($model);
$table = $this->fullTableName($model, false, false);
$fields = parent::describe($table);
$this->_sequenceMap[$table] = array();
$cols = null;

Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Datasource/Database/Sqlite.php
Expand Up @@ -160,11 +160,11 @@ public function listSources($data = null) {
* @return array Fields in table. Keys are name and type
*/
public function describe($model) {
$cache = parent::describe($model);
$table = $this->fullTableName($model, false, false);
$cache = parent::describe($table);
if ($cache != null) {
return $cache;
}
$table = $this->fullTableName($model, false, false);
$fields = array();
$result = $this->_execute('PRAGMA table_info(' . $table . ')');

Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -201,7 +201,8 @@ public function listSources($data = null) {
* @throws CakeException
*/
public function describe($model) {
$cache = parent::describe($model);
$table = $this->fullTableName($model, false);
$cache = parent::describe($table);
if ($cache != null) {
return $cache;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php
Expand Up @@ -168,6 +168,7 @@ public function __construct() {
$this->Permission->Aro = $this->Aro;
$this->Permission->Aco = $this->Aco;
}

}

/**
Expand All @@ -176,6 +177,7 @@ public function __construct() {
* @package Cake.Test.Case.Controller.Component.Acl
*/
class DbAclTest extends CakeTestCase {

/**
* fixtures property
*
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php
Expand Up @@ -31,7 +31,7 @@ class IniAclTest extends CakeTestCase {
* @return void
*/
public function testCheck() {
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS . 'acl.ini.php';
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';

$Ini = new IniAcl();
$Ini->config = $Ini->readConfigFile($iniFile);
Expand All @@ -54,7 +54,7 @@ public function testCheck() {
* @return void
*/
public function testCheckArray() {
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS . 'acl.ini.php';
$iniFile = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.ini.php';

$Ini = new IniAcl();
$Ini->config = $Ini->readConfigFile($iniFile);
Expand Down
27 changes: 8 additions & 19 deletions lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php
Expand Up @@ -34,12 +34,11 @@ public function setUp() {
$this->PhpAcl = new PhpAcl();
$this->Acl = new AclComponent($Collection, array(
'adapter' => array(
'config' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS . 'acl.php',
'config' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.php',
),
));
}


public function testRoleInheritance() {
$roles = $this->Acl->Aro->roles('User/peter');
$this->assertEquals(array('Role/accounting'), $roles[0]);
Expand All @@ -52,14 +51,12 @@ public function testRoleInheritance() {
$this->assertEquals(array('User/hardy'), $roles[3]);
}


public function testAddRole() {
$this->assertEquals(array(array(PhpAro::DEFAULT_ROLE)), $this->Acl->Aro->roles('foobar'));
$this->Acl->Aro->addRole(array('User/foobar' => 'Role/accounting'));
$this->assertEquals(array(array('Role/accounting'), array('User/foobar')), $this->Acl->Aro->roles('foobar'));
}


public function testAroResolve() {
$map = $this->Acl->Aro->map;
$this->Acl->Aro->map = array(
Expand All @@ -73,7 +70,7 @@ public function testAroResolve() {
$this->assertEquals('User/hardy', $this->Acl->Aro->resolve(array('FooModel' => array('nickname' => 'hardy'))));
$this->assertEquals('Role/admin', $this->Acl->Aro->resolve(array('FooModel' => array('role' => 'admin'))));
$this->assertEquals('Role/admin', $this->Acl->Aro->resolve('Role/admin'));

$this->assertEquals('Role/admin', $this->Acl->Aro->resolve('admin'));
$this->assertEquals('Role/admin', $this->Acl->Aro->resolve('FooModel/admin'));
$this->assertEquals('Role/accounting', $this->Acl->Aro->resolve('accounting'));
Expand All @@ -93,7 +90,7 @@ public function testAroAliases() {

$this->Acl->Aro->aliases = array(
'Role/1' => 'Role/admin',
'Role/24' => 'Role/accounting',
'Role/24' => 'Role/accounting',
);

$user = array(
Expand Down Expand Up @@ -127,12 +124,11 @@ public function testAroAliases() {
$this->assertFalse($this->Acl->check($user, '/controllers/users/dashboard'));

$this->assertFalse($this->Acl->check($user, '/controllers/invoices/send'));
// wee add an more specific entry for user foo to also inherit from Role/accounting
// wee add an more specific entry for user foo to also inherit from Role/accounting
$this->Acl->Aro->addRole(array('User/foo' => 'Role/IT, Role/accounting'));
$this->assertTrue($this->Acl->check($user, '/controllers/invoices/send'));
}


/**
* test check method
*
Expand All @@ -146,7 +142,7 @@ public function testCheck() {
$this->assertTrue($this->Acl->check('jan', 'foo/bar'));
$this->assertTrue($this->Acl->check('user/jan', 'foo/bar'));
$this->assertTrue($this->Acl->check('Role/admin', 'controllers/bar'));
$this->assertTrue($this->Acl->check(array('User' => array('username' =>'jan')), '/controllers/bar/bll'));
$this->assertTrue($this->Acl->check(array('User' => array('username' => 'jan')), '/controllers/bar/bll'));
$this->assertTrue($this->Acl->check('Role/database_manager', 'controllers/db/create'));
$this->assertTrue($this->Acl->check('User/db_manager_2', 'controllers/db/create'));
$this->assertFalse($this->Acl->check('db_manager_2', '/controllers/users/Dashboard'));
Expand Down Expand Up @@ -184,7 +180,6 @@ public function testCheck() {
$this->assertFalse($this->Acl->check('role/accounting', 'controllers/articles/publish'));
}


/**
* lhs of defined rules are case insensitive
*/
Expand All @@ -195,7 +190,6 @@ public function testCheckIsCaseInsensitive() {
$this->assertTrue($this->Acl->check('Role/data_acquirer', 'controllers/FORMS/NEW'));
}


/**
* allow should work in-memory
*/
Expand All @@ -216,7 +210,6 @@ public function testAllow() {
$this->assertFalse($this->Acl->check('Role/reports', 'foo/bar'));
}


/**
* deny should work in-memory
*/
Expand All @@ -231,11 +224,10 @@ public function testDeny() {
$this->assertTrue($this->Acl->check('stan', 'controllers/baz/manager_foooooo'));
}


/**
* test that a deny rule wins over an equally specific allow rule
*/
public function testDenyRuleIsStrongerThanAllowRule() {
public function testDenyRuleIsStrongerThanAllowRule() {
$this->assertFalse($this->Acl->check('peter', 'baz/bam'));
$this->Acl->allow('peter', 'baz/bam');
$this->assertTrue($this->Acl->check('peter', 'baz/bam'));
Expand All @@ -256,7 +248,6 @@ public function testDenyRuleIsStrongerThanAllowRule() {
$this->assertFalse($this->Acl->check('stan', 'controllers/reports/delete'));
}


/**
* test that an invalid configuration throws exception
*/
Expand All @@ -269,7 +260,6 @@ public function testInvalidConfigWithAroMissing() {
$this->PhpAcl->build($config);
}


public function testInvalidConfigWithAcosMissing() {
$this->setExpectedException(
'AclException',
Expand All @@ -291,7 +281,7 @@ public function testAcoResolve() {
$this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('foo/bar'));
$this->assertEquals(array('foo', 'bar', 'baz'), $this->Acl->Aco->resolve('foo/bar/baz'));
$this->assertEquals(array('foo', '*-bar', '?-baz'), $this->Acl->Aco->resolve('foo/*-bar/?-baz'));

$this->assertEquals(array('foo', 'bar', '[a-f0-9]{24}', '*_bla', 'bla'), $this->Acl->Aco->resolve('foo/bar/[a-f0-9]{24}/*_bla/bla'));

// multiple slashes will be squashed to a single, trimmed and then exploded
Expand All @@ -318,14 +308,13 @@ public function testAroDeclarationContainsCycles() {
'allow' => array(
'*' => 'Role/a',
),
),
),
);

$this->expectError('PHPUnit_Framework_Error', 'cycle detected' /* ... */);
$this->PhpAcl->build($config);
}


/**
* test that with policy allow, only denies count
*/
Expand Down
Expand Up @@ -25,6 +25,7 @@ class_exists('AclComponent');
* @package Cake.Test.Case.Controller.Component
*/
class AclComponentTest extends CakeTestCase {

/**
* setUp method
*
Expand Down
Expand Up @@ -24,7 +24,7 @@
App::uses('CakeResponse', 'Network');


require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php';
require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php';

/**
* Test case for BasicAuthentication
Expand Down
Expand Up @@ -114,7 +114,6 @@ public function testAuthorizeCheckFailure() {
$this->assertFalse($this->auth->authorize($user['User'], $request));
}


/**
* test getting actionMap
*
Expand Down
Expand Up @@ -22,7 +22,7 @@
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');

require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php';
require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php';

/**
* Test case for DigestAuthentication
Expand Down
Expand Up @@ -23,7 +23,7 @@
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');

require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php';
require_once CAKE . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'models.php';

/**
* Test case for FormAuthentication
Expand Down

0 comments on commit 5687d97

Please sign in to comment.