Permalink
Browse files

Merge branch '1.3' of git://github.com/cakephp/cakephp into 1.3

  • Loading branch information...
2 parents 1f473f5 + 1cdf55f commit c918395fb4edbeee5f466aec6e78521617b7bbb4 @ceeram ceeram committed May 8, 2011
View
@@ -548,6 +548,18 @@ function settings($name = null) {
}
return array();
}
+
+/**
+ * Write the session when session data is persisted with cache.
+ *
+ * @return void
+ * @access public
+ */
+ function __destruct() {
+ if (Configure::read('Session.save') == 'cache' && function_exists('session_write_close')) {
+ session_write_close();
+ }
+ }
}
/**
@@ -841,7 +841,7 @@ function &getModel($name = null) {
*/
function identify($user = null, $conditions = null) {
if ($conditions === false) {
- $conditions = null;
+ $conditions = array();
} elseif (is_array($conditions)) {
$conditions = array_merge((array)$this->userScope, $conditions);
} else {
@@ -553,6 +553,49 @@ function testIsErrorOrTests() {
}
/**
+ * testIdentify method
+ *
+ * @access public
+ * @return void
+ */
+ function testIdentify() {
+ $this->AuthUser =& new AuthUser();
+ $user['id'] = 1;
+ $user['username'] = 'mariano';
+ $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake');
+ $this->AuthUser->save($user, false);
+
+ $this->Controller->Auth->initialize($this->Controller);
+ $this->Controller->Auth->userModel = 'AuthUser';
+ $this->Controller->Auth->startup($this->Controller);
+ $this->assertTrue($this->Controller->Auth->identify($user));
+ }
+
+/**
+ * testIdentifyWithConditions method
+ *
+ * @access public
+ * @return void
+ */
+ function testIdentifyWithConditions() {
+ $this->AuthUser =& new AuthUser();
+ $user['id'] = 1;
+ $user['username'] = 'mariano';
+ $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake');
+ $this->AuthUser->save($user, false);
+
+ $this->Controller->Auth->initialize($this->Controller);
+ $this->Controller->Auth->startup($this->Controller);
+ $this->Controller->Auth->userModel = 'AuthUser';
+
+ $this->assertFalse($this->Controller->Auth->identify($user, array('AuthUser.id >' => 2)));
+
+ $this->Controller->Auth->userScope = array('id >' => 2);
+ $this->assertFalse($this->Controller->Auth->identify($user));
+ $this->assertTrue($this->Controller->Auth->identify($user, false));
+ }
+
+/**
* testLogin method
*
* @access public

0 comments on commit c918395

Please sign in to comment.