Merge branch '2.1' into 2.2

This commit is contained in:
mark_story 2012-03-12 20:31:33 -04:00
commit 5687d97a98
30 changed files with 208 additions and 144 deletions

View file

@ -120,8 +120,8 @@ class Component extends Object {
}
/**
* 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

View file

@ -484,7 +484,7 @@ class CakeSchema extends Object {
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;
}
}

View file

@ -297,7 +297,8 @@ class Mysql extends DboSource {
* @throws CakeException
*/
public function describe($model) {
$cache = parent::describe($model);
$key = $this->fullTableName($model, false);
$cache = parent::describe($key);
if ($cache != null) {
return $cache;
}
@ -331,7 +332,7 @@ class Mysql extends DboSource {
}
}
}
$this->_cacheDescription($this->fullTableName($model, false), $fields);
$this->_cacheDescription($key, $fields);
$cols->closeCursor();
return $fields;
}

View file

@ -186,8 +186,8 @@ class Postgres extends DboSource {
* @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;

View file

@ -160,11 +160,11 @@ class Sqlite extends DboSource {
* @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 . ')');

View file

@ -201,7 +201,8 @@ class Sqlserver extends DboSource {
* @throws CakeException
*/
public function describe($model) {
$cache = parent::describe($model);
$table = $this->fullTableName($model, false);
$cache = parent::describe($table);
if ($cache != null) {
return $cache;
}

View file

@ -168,6 +168,7 @@ class DbAclTwoTest extends DbAcl {
$this->Permission->Aro = $this->Aro;
$this->Permission->Aco = $this->Aco;
}
}
/**
@ -176,6 +177,7 @@ class DbAclTwoTest extends DbAcl {
* @package Cake.Test.Case.Controller.Component.Acl
*/
class DbAclTest extends CakeTestCase {
/**
* fixtures property
*

View file

@ -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);
@ -54,7 +54,7 @@ class IniAclTest extends CakeTestCase {
* @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);

View file

@ -34,12 +34,11 @@ class PhpAclTest extends CakeTestCase {
$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]);
@ -52,14 +51,12 @@ class PhpAclTest extends CakeTestCase {
$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(
@ -73,7 +70,7 @@ class PhpAclTest extends CakeTestCase {
$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'));
@ -93,7 +90,7 @@ class PhpAclTest extends CakeTestCase {
$this->Acl->Aro->aliases = array(
'Role/1' => 'Role/admin',
'Role/24' => 'Role/accounting',
'Role/24' => 'Role/accounting',
);
$user = array(
@ -127,12 +124,11 @@ class PhpAclTest extends CakeTestCase {
$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
*
@ -146,7 +142,7 @@ class PhpAclTest extends CakeTestCase {
$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'));
@ -184,7 +180,6 @@ class PhpAclTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('role/accounting', 'controllers/articles/publish'));
}
/**
* lhs of defined rules are case insensitive
*/
@ -195,7 +190,6 @@ class PhpAclTest extends CakeTestCase {
$this->assertTrue($this->Acl->check('Role/data_acquirer', 'controllers/FORMS/NEW'));
}
/**
* allow should work in-memory
*/
@ -216,7 +210,6 @@ class PhpAclTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('Role/reports', 'foo/bar'));
}
/**
* deny should work in-memory
*/
@ -231,11 +224,10 @@ class PhpAclTest extends CakeTestCase {
$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'));
@ -256,7 +248,6 @@ class PhpAclTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('stan', 'controllers/reports/delete'));
}
/**
* test that an invalid configuration throws exception
*/
@ -269,7 +260,6 @@ class PhpAclTest extends CakeTestCase {
$this->PhpAcl->build($config);
}
public function testInvalidConfigWithAcosMissing() {
$this->setExpectedException(
'AclException',
@ -291,7 +281,7 @@ class PhpAclTest extends CakeTestCase {
$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
@ -318,14 +308,13 @@ class PhpAclTest extends CakeTestCase {
'allow' => array(
'*' => 'Role/a',
),
),
),
);
$this->expectError('PHPUnit_Framework_Error', 'cycle detected' /* ... */);
$this->PhpAcl->build($config);
}
/**
* test that with policy allow, only denies count
*/

View file

@ -25,6 +25,7 @@ class_exists('AclComponent');
* @package Cake.Test.Case.Controller.Component
*/
class AclComponentTest extends CakeTestCase {
/**
* setUp method
*

View file

@ -24,7 +24,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 BasicAuthentication

View file

@ -114,7 +114,6 @@ class CrudAuthorizeTest extends CakeTestCase {
$this->assertFalse($this->auth->authorize($user['User'], $request));
}
/**
* test getting actionMap
*

View file

@ -22,7 +22,7 @@ App::uses('AppModel', 'Model');
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

View file

@ -23,7 +23,7 @@ App::uses('AppModel', 'Model');
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

View file

@ -23,11 +23,11 @@ App::uses('AclComponent', 'Controller/Component');
App::uses('FormAuthenticate', 'Controller/Component/Auth');
/**
* TestAuthComponent class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
* TestAuthComponent class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
class TestAuthComponent extends AuthComponent {
/**
@ -53,11 +53,11 @@ class TestAuthComponent extends AuthComponent {
}
/**
* AuthUser class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
* AuthUser class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
class AuthUser extends CakeTestModel {
/**
@ -77,11 +77,11 @@ class AuthUser extends CakeTestModel {
}
/**
* AuthTestController class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
* AuthTestController class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
class AuthTestController extends Controller {
/**
@ -155,7 +155,6 @@ class AuthTestController extends Controller {
* @return void
*/
public function logout() {
}
/**
@ -195,7 +194,6 @@ class AuthTestController extends Controller {
* @return void
*/
public function isAuthorized() {
}
}
@ -269,14 +267,15 @@ class AjaxAuthController extends Controller {
$this->testUrl = Router::url($url);
return false;
}
}
/**
* AuthComponentTest class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
* AuthComponentTest class
*
* @package Cake.Test.Case.Controller.Component
* @package Cake.Test.Case.Controller.Component
*/
class AuthComponentTest extends CakeTestCase {
/**
@ -951,7 +950,7 @@ class AuthComponentTest extends CakeTestCase {
*/
public function testAjaxLogin() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";
@ -1225,6 +1224,6 @@ class AuthComponentTest extends CakeTestCase {
$result = $this->Auth->password('password');
$expected = Security::hash('password', null, true);
$this->assertEquals($expected, $result);
}
}

View file

@ -49,6 +49,7 @@ class CookieComponentTestController extends Controller {
$this->Cookie->secure = false;
$this->Cookie->key = 'somerandomhaskey';
}
}
/**
@ -191,7 +192,7 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->secure = false;
$this->Cookie->write('Testing', 'value', false);
$expected = array(
'name' => $this->Cookie->name.'[Testing]',
'name' => $this->Cookie->name . '[Testing]',
'value' => 'value',
'expire' => time() + 10,
'path' => '/',
@ -212,7 +213,7 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->secure = false;
$this->Cookie->delete('Testing', false);
$expected = array(
'name' => $this->Cookie->name.'[Testing]',
'name' => $this->Cookie->name . '[Testing]',
'value' => '',
'expire' => time() - 42000,
'path' => '/',
@ -249,14 +250,14 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie->secure = false;
$this->Cookie->write('Testing', array(1, 2, 3), false);
$expected = array(
'name' => $this->Cookie->name.'[Testing]',
'name' => $this->Cookie->name . '[Testing]',
'value' => '[1,2,3]',
'expire' => time() + 10,
'path' => '/',
'domain' => '',
'secure' => false,
'httpOnly' => false);
$result = $this->Controller->response->cookie($this->Cookie->name.'[Testing]');
$result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]');
$this->assertEquals($result, $expected);
}
@ -516,7 +517,6 @@ class CookieComponentTest extends CakeTestCase {
$this->assertNull($this->Cookie->read('value'));
}
/**
* test that deleting a top level keys kills the child elements too.
*

View file

@ -160,7 +160,7 @@ class EmailComponentTest extends CakeTestCase {
self::$sentDate = date(DATE_RFC2822);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
}
@ -301,10 +301,10 @@ HTMLBLOC;
"\n\n" .
'--alt-{boundary}' . "\n" .
'Content-Type: text/html; charset=UTF-8' . "\n" .
'Content-Transfer-Encoding: 8bit' . "\n\n" .
'Content-Transfer-Encoding: 8bit' . "\n\n" .
$html .
"\n\n" .
'--alt-{boundary}--' . "\n\n\n" .
"\n\n" .
'--alt-{boundary}--' . "\n\n\n" .
'--{boundary}--' . "\n";
$expect = '<pre>' . $expect . '</pre>';
@ -429,7 +429,7 @@ HTMLBLOC;
*/
public function testMessageRetrievalWithoutTemplate() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$this->Controller->EmailTest->to = 'postmaster@example.com';
@ -466,7 +466,7 @@ HTMLBLOC;
*/
public function testMessageRetrievalWithTemplate() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$this->Controller->set('value', 22091985);
@ -526,7 +526,7 @@ HTMLBLOC;
*/
public function testMessageRetrievalWithHelper() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$timestamp = time();
@ -624,7 +624,7 @@ HTMLBLOC;
*
* @return void
*/
public function test_encodeSettingInternalCharset() {
public function testEncodeSettingInternalCharset() {
$this->skipIf(!function_exists('mb_internal_encoding'), 'Missing mb_* functions, cannot run test.');
$restore = mb_internal_encoding();
@ -820,7 +820,7 @@ HTMLBLOC;
public function testPluginCustomViewClass() {
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$this->Controller->view = 'TestPlugin.Email';
@ -835,7 +835,6 @@ HTMLBLOC;
$result = DebugCompTransport::$lastEmail;
$this->assertRegExp('/Body of message/', $result);
}
/**

View file

@ -30,6 +30,7 @@ App::uses('CakeResponse', 'Network');
* @package Cake.Test.Case.Controller.Component
*/
class PaginatorTestController extends Controller {
/**
* name property
*
@ -37,13 +38,6 @@ class PaginatorTestController extends Controller {
*/
public $name = 'PaginatorTest';
/**
* uses property
*
* @var array
*/
//public $uses = null;
/**
* components property
*
@ -113,12 +107,13 @@ class PaginatorControllerPost extends CakeTestModel {
*/
public function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
if ($conditions == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
$conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1');
$options = Set::merge($fields, compact('conditions'));
return parent::find('all', $options);
}
return parent::find($conditions, $fields);
}
}
/**
@ -159,6 +154,7 @@ class ControllerPaginateModel extends CakeTestModel {
public function paginateCount($conditions, $recursive, $extra) {
$this->extraCount = $extra;
}
}
/**
@ -942,7 +938,7 @@ class PaginatorComponentTest extends CakeTestCase {
$Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '5000');
$result = $Controller->paginate('PaginatorControllerPost');
$this->assertEquals($Controller->params['paging']['PaginatorControllerPost']['options']['limit'], 2000);
}
}
/**
* test paginate() and virtualField overlapping with real fields.

View file

@ -67,6 +67,7 @@ class RequestHandlerTestController extends Controller {
}
$this->destination();
}
}
@ -229,7 +230,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->RequestHandler->initialize($this->Controller);
$this->assertNull($this->RequestHandler->ext);
}
/**
* Test that ext is not set with confusing android accepts headers.
*
@ -292,7 +293,6 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->assertEquals($this->Controller->ext, '.ctp');
}
/**
* testAutoAjaxLayout method
*
@ -522,7 +522,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$result = $this->RequestHandler->requestedWith(array('json', 'xml'));
$this->assertEquals($result, 'json');
$result =$this->RequestHandler->requestedWith(array('rss', 'atom'));
$result = $this->RequestHandler->requestedWith(array('rss', 'atom'));
$this->assertFalse($result);
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';
@ -711,7 +711,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
*/
public function testAjaxRedirectAsRequestAction() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
$this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
@ -740,7 +740,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
*/
public function testAjaxRedirectAsRequestActionStillRenderingLayout() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
$this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
@ -831,7 +831,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
public function testCheckNotModifiedByEtagStar() {
$_SERVER['HTTP_IF_NONE_MATCH'] = '*';
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response->etag('something');
$RequestHandler->response->expects($this->once())->method('notModified');
$this->assertFalse($RequestHandler->beforeRender($this->Controller));
@ -845,7 +845,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
public function testCheckNotModifiedByEtagExact() {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response->etag('something', true);
$RequestHandler->response->expects($this->once())->method('notModified');
$this->assertFalse($RequestHandler->beforeRender($this->Controller));
@ -860,7 +860,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response->etag('something', true);
$RequestHandler->response->modified('2012-01-01 00:00:00');
$RequestHandler->response->expects($this->once())->method('notModified');
@ -874,7 +874,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
**/
public function testCheckNotModifiedNoInfo() {
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response = $this->getMock('CakeResponse', array('notModified'));
$RequestHandler->response->expects($this->never())->method('notModified');
$this->assertNull($RequestHandler->beforeRender($this->Controller));
}

View file

@ -21,10 +21,10 @@ App::uses('SecurityComponent', 'Controller/Component');
App::uses('Controller', 'Controller');
/**
* TestSecurityComponent
*
* @package Cake.Test.Case.Controller.Component
*/
* TestSecurityComponent
*
* @package Cake.Test.Case.Controller.Component
*/
class TestSecurityComponent extends SecurityComponent {
/**
@ -36,13 +36,14 @@ class TestSecurityComponent extends SecurityComponent {
public function validatePost(Controller $controller) {
return $this->_validatePost($controller);
}
}
/**
* SecurityTestController
*
* @package Cake.Test.Case.Controller.Component
*/
* SecurityTestController
*
* @package Cake.Test.Case.Controller.Component
*/
class SecurityTestController extends Controller {
/**
@ -103,6 +104,7 @@ class SecurityTestController extends Controller {
public function header($status) {
$this->testHeaders[] = $status;
}
}
/**
@ -677,7 +679,6 @@ class SecurityComponentTest extends CakeTestCase {
$result = $this->Controller->Security->validatePost($this->Controller);
$this->assertTrue($result);
$this->Controller->request->data = array();
$this->Controller->Security->startup($this->Controller);
$key = $this->Controller->request->params['_Token']['key'];
@ -912,7 +913,6 @@ class SecurityComponentTest extends CakeTestCase {
* @return void
*/
public function testValidateNestedNumericSets() {
$this->Controller->Security->startup($this->Controller);
$key = $this->Controller->request->params['_Token']['key'];
$unlocked = '';
@ -1181,7 +1181,6 @@ class SecurityComponentTest extends CakeTestCase {
$tokens = $this->Security->Session->read('_Token.csrfTokens');
$this->assertEquals(2, count($tokens), 'Too many tokens left behind');
$this->assertNotEmpty('valid', $tokens, 'Valid token was removed.');
}
/**
@ -1261,9 +1260,9 @@ class SecurityComponentTest extends CakeTestCase {
$this->assertEquals(1, count($token), 'Should only be one token.');
$this->Security->startup($this->Controller);
$token2 = $this->Security->Session->read('_Token.csrfTokens');
$this->assertEquals(1, count($token2), 'Should only be one token.');
$this->assertEquals($token, $token2, 'Tokens should not be different.');
$tokenTwo = $this->Security->Session->read('_Token.csrfTokens');
$this->assertEquals(1, count($tokenTwo), 'Should only be one token.');
$this->assertEquals($token, $tokenTwo, 'Tokens should not be different.');
$key = $this->Controller->request->params['_Token']['key'];
$this->assertEquals(array($key), array_keys($token), '_Token.key and csrfToken do not match request will blackhole.');

View file

@ -34,13 +34,14 @@ class SessionTestController extends Controller {
public $uses = array();
/**
* session_id method
* sessionId method
*
* @return string
*/
public function session_id() {
public function sessionId() {
return $this->Session->id();
}
}
/**
@ -58,13 +59,14 @@ class OrangeSessionTestController extends Controller {
public $uses = array();
/**
* session_id method
* sessionId method
*
* @return string
*/
public function session_id() {
public function sessionId() {
return $this->Session->id();
}
}
/**
@ -141,10 +143,10 @@ class SessionComponentTest extends CakeTestCase {
$Session = new SessionComponent($this->ComponentCollection);
$expected = $Session->id();
$result = $Object->requestAction('/session_test/session_id');
$result = $Object->requestAction('/session_test/sessionId');
$this->assertEquals($expected, $result);
$result = $Object->requestAction('/orange_session_test/session_id');
$result = $Object->requestAction('/orange_session_test/sessionId');
$this->assertEquals($expected, $result);
}

View file

@ -28,6 +28,7 @@ class CookieAliasComponent extends CookieComponent {
}
class ComponentCollectionTest extends CakeTestCase {
/**
* setUp
*

View file

@ -95,6 +95,7 @@ class AppleComponent extends Component {
public function startup(Controller $controller) {
$this->testName = $controller->name;
}
}
/**
@ -131,6 +132,7 @@ class OrangeComponent extends Component {
public function startup(Controller $controller) {
$controller->foo = 'pass';
}
}
/**
@ -156,6 +158,7 @@ class BananaComponent extends Component {
public function startup(Controller $controller) {
$controller->bar = 'fail';
}
}
/**

View file

@ -25,6 +25,7 @@ App::uses('CookieComponent', 'Controller/Component');
* @package Cake.Test.Case.Controller
*/
class ControllerTestAppController extends Controller {
/**
* helpers property
*
@ -102,12 +103,13 @@ class ControllerPost extends CakeTestModel {
*/
public function find($type = 'first', $options = array()) {
if ($type == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
$conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1');
$options = Set::merge($options, compact('conditions'));
return parent::find('all', $options);
}
return parent::find($type, $options);
}
}
/**
@ -262,14 +264,13 @@ class TestController extends ControllerTestAppController {
* @param mixed $test2Id
* @return void
*/
public function index($testId, $test2Id) {
public function index($testId, $testTwoId) {
$this->data = array(
'testId' => $testId,
'test2Id' => $test2Id
'test2Id' => $testTwoId
);
}
/**
* view method
*
@ -277,10 +278,10 @@ class TestController extends ControllerTestAppController {
* @param mixed $test2Id
* @return void
*/
public function view($testId, $test2Id) {
public function view($testId, $testTwoId) {
$this->data = array(
'testId' => $testId,
'test2Id' => $test2Id
'test2Id' => $testTwoId
);
}
@ -289,20 +290,17 @@ class TestController extends ControllerTestAppController {
}
protected function protected_m() {
}
private function private_m() {
}
public function _hidden() {
}
public function admin_add() {
}
}
/**
@ -311,6 +309,7 @@ class TestController extends ControllerTestAppController {
* @package Cake.Test.Case.Controller
*/
class TestComponent extends Object {
/**
* beforeRedirect method
*
@ -353,14 +352,15 @@ class TestComponent extends Object {
$controller->viewClass = $this->viewclass;
}
}
}
class Test2Component extends TestComponent {
public function beforeRender(Controller $controller) {
return false;
}
}
/**
@ -555,11 +555,11 @@ class ControllerTest extends CakeTestCase {
</body>
</html>';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEquals($expected, $result);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$Controller = new Controller($request);
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
@ -609,7 +609,6 @@ class ControllerTest extends CakeTestCase {
$Controller->set(array(1 => 'one', 2 => 'two'));
$expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two');
$this->assertEquals($Controller->viewVars, $expected);
}
/**
@ -619,7 +618,7 @@ class ControllerTest extends CakeTestCase {
*/
public function testRender() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
ClassRegistry::flush();
$request = new CakeRequest('controller_posts/index');
@ -671,7 +670,7 @@ class ControllerTest extends CakeTestCase {
public function testComponentBeforeRenderChangingViewClass() {
App::build(array(
'View' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
)
), true);
$Controller = new Controller($this->getMock('CakeRequest'), new CakeResponse());
@ -700,7 +699,6 @@ class ControllerTest extends CakeTestCase {
$this->assertInstanceOf('CakeResponse', $result);
}
/**
* testToBeInheritedGuardmethods method
*
@ -911,20 +909,17 @@ class ControllerTest extends CakeTestCase {
$appVars = get_class_vars('ControllerTestAppController');
$testVars = get_class_vars('AnotherTestController');
$this->assertTrue(in_array('ControllerPost', $appVars['uses']));
$this->assertFalse($testVars['uses']);
$this->assertFalse(property_exists($TestController, 'ControllerPost'));
$TestController = new ControllerCommentsController($request);
$TestController->constructClasses();
$appVars = get_class_vars('ControllerTestAppController');
$testVars = get_class_vars('ControllerCommentsController');
$this->assertTrue(in_array('ControllerPost', $appVars['uses']));
$this->assertEquals(array('ControllerPost'), $testVars['uses']);
@ -1082,7 +1077,6 @@ class ControllerTest extends CakeTestCase {
$result = $Controller->postConditions($data);
$this->assertSame($expected, $result);
$data = array();
$Controller->data = array(
'Model1' => array('field1' => '23'),
@ -1097,13 +1091,11 @@ class ControllerTest extends CakeTestCase {
$result = $Controller->postConditions($data);
$this->assertSame($expected, $result);
$data = array();
$Controller->data = array();
$result = $Controller->postConditions($data);
$this->assertNull($result);
$data = array();
$Controller->data = array(
'Model1' => array('field1' => '23'),
@ -1414,5 +1406,4 @@ class ControllerTest extends CakeTestCase {
$this->assertEquals('I am from the controller.', $result);
}
}

View file

@ -34,7 +34,7 @@ class PagesControllerTest extends CakeTestCase {
public function testDisplay() {
App::build(array(
'View' => array(
CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
)
));
$Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());

View file

@ -76,6 +76,7 @@ class ScaffoldMockControllerWithFields extends Controller {
$this->set('scaffoldFields', array('title'));
return true;
}
}
/**
@ -102,6 +103,7 @@ class TestScaffoldMock extends Scaffold {
public function getParams() {
return $this->_params;
}
}
/**
@ -344,4 +346,5 @@ class ScaffoldTest extends CakeTestCase {
$this->assertNotRegExp('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
}
}

View file

@ -642,11 +642,11 @@ class CakeSchemaTest extends CakeTestCase {
*/
public function testSchemaReadWithConfigPrefix() {
$this->skipIf($this->db instanceof Sqlite, 'Cannot open 2 connections to Sqlite');
$db = ConnectionManager::getDataSource('test');
$config = $db->config;
$this->skipIf(!empty($config['prefix']), 'This test can not be executed with datasource prefix set.');
$config['prefix'] = 'schema_test_prefix_';
ConnectionManager::create('schema_prefix', $config);
$read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false));
@ -964,6 +964,54 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertEquals($expected, $compare);
}
/**
* Test comparing with field changed from VARCHAR to DATETIME
*
* @return void
*/
public function testCompareVarcharToDatetime() {
$old = array(
'posts' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
'author_id' => array('type' => 'integer', 'null' => false),
'title' => array('type' => 'string', 'null' => true, 'length' => 45),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => true)
),
'tableParameters' => array(
'charset' => 'latin1',
'collate' => 'latin1_general_ci'
)
),
);
$new = array(
'posts' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
'author_id' => array('type' => 'integer', 'null' => false),
'title' => array('type' => 'datetime', 'null' => false),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => true)
),
'tableParameters' => array(
'charset' => 'latin1',
'collate' => 'latin1_general_ci'
)
),
);
$compare = $this->Schema->compare($old, $new);
$expected = array(
'posts' => array(
'change' => array(
'title' => array(
'type' => 'datetime',
'null' => false,
)
)
),
);
$this->assertEquals($expected, $compare, 'Invalid SQL, datetime does not have length');
}
/**
* testSchemaLoading method
*

View file

@ -365,6 +365,30 @@ class SetTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* test sorting with string keys.
*
* @return void
*/
public function testSortString() {
$to_sort = array(
'four' => array('number' => 4, 'some' => 'foursome'),
'six' => array('number' => 6, 'some' => 'sixsome'),
'five' => array('number' => 5, 'some' => 'fivesome'),
'two' => array('number' => 2, 'some' => 'twosome'),
'three' => array('number' => 3, 'some' => 'threesome')
);
$sorted = Set::sort($to_sort, '{s}.number', 'asc');
$expected = array(
'two' => array('number' => 2, 'some' => 'twosome'),
'three' => array('number' => 3, 'some' => 'threesome'),
'four' => array('number' => 4, 'some' => 'foursome'),
'five' => array('number' => 5, 'some' => 'fivesome'),
'six' => array('number' => 6, 'some' => 'sixsome')
);
$this->assertEquals($expected, $sorted);
}
/**
* test sorting with out of order keys.
*

View file

@ -706,8 +706,8 @@ class Debugger {
$files = $this->trace(array('start' => $data['start'], 'format' => 'points'));
$code = '';
if (isset($files[0]['file'])) {
$code = $this->excerpt($files[0]['file'], $files[0]['line'] - 1, 1);
if (isset($files[1]['file'])) {
$code = $this->excerpt($files[1]['file'], $files[1]['line'] - 1, 1);
}
$trace = $this->trace(array('start' => $data['start'], 'depth' => '20'));
$insertOpts = array('before' => '{:', 'after' => '}');

View file

@ -34,7 +34,7 @@ class Set {
* Since this method emulates `array_merge`, it will re-order numeric keys. When combined with out of
* order numeric keys containing arrays, results can be lossy.
*
* Note: This function will work with an unlimited amount of arguments and typecasts non-array
* Note: This function will work with an unlimited amount of arguments and typecasts non-array
* parameters into arrays.
*
* @param array $arr1 Array to be merged
@ -322,7 +322,7 @@ class Set {
/**
* Implements partial support for XPath 2.0. If $path does not contain a '/' the call
* is delegated to Set::classicExtract(). Also the $path and $data arguments are
* is delegated to Set::classicExtract(). Also the $path and $data arguments are
* reversible.
*
* #### Currently implemented selectors:
@ -982,7 +982,7 @@ class Set {
$new = array_merge($new, Set::reverse($value));
} else {
$new[$key] = Set::reverse($value);
}
}
// @codingStandardsIgnoreEnd
}
}
@ -1070,8 +1070,10 @@ class Set {
*/
public static function sort($data, $path, $dir) {
$originalKeys = array_keys($data);
$numeric = false;
if (is_numeric(implode('', $originalKeys))) {
$data = array_values($data);
$numeric = true;
}
$result = Set::_flatten(Set::extract($data, $path));
list($keys, $values) = array(Set::extract($result, '{n}.id'), Set::extract($result, '{n}.value'));
@ -1087,7 +1089,11 @@ class Set {
$keys = array_unique($keys);
foreach ($keys as $k) {
$sorted[] = $data[$k];
if (!$numeric) {
$sorted[$originalKeys[$k]] = $data[$originalKeys[$k]];
} else {
$sorted[] = $data[$k];
}
}
return $sorted;
}