Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding tests for Auth::identify()

  • Loading branch information...
commit 527ff5feaf1fd46c2702bc95688d50fea5352854 1 parent d9c7f4d
@ceeram ceeram authored markstory committed
Showing with 43 additions and 0 deletions.
  1. +43 −0 cake/tests/cases/libs/controller/components/auth.test.php
View
43 cake/tests/cases/libs/controller/components/auth.test.php
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.