예제 #1
0
 /**
  * Test get password
  *
  */
 public function testSetPassword()
 {
     $password = 654321;
     $this->_user->password = $password;
     $this->_user->save();
     $this->assertTrue(Users_Model_User_Manager::authenticate($this->_user->login, $password));
 }
 /**
  * Test register user
  *
  * @todo unable provide test without advanced mocking
  */
 public function testRegisterUser()
 {
     $this->dispatch('/users/register/');
     $this->assertQuery('form#userRegisterForm');
     $html = $this->response->getBody();
     $this->resetRequest();
     $this->resetResponse();
     // TODO:
     // 1. Change email address to config email.
     // 2. Make the address in config as stub for test emails
     $this->_fixture['captcha'] = $this->getCaptcha($html);
     //$this->markTestIncomplete('todo mock registration form');
     $this->request->setMethod('POST')->setPost($this->_fixture);
     $this->dispatch("/users/register/");
     //$this->assertRedirectTo("/");
     $user = $this->_userTable->getByLogin($this->_fixture['login']);
     $this->assertNotNull($user->id);
     $user->status = Users_Model_User::STATUS_ACTIVE;
     $user->save();
     $auth = Users_Model_User_Manager::authenticate($this->_fixture['login'], $this->_fixture['password']);
     $this->assertTrue($auth);
     Users_Model_User_Manager::logout();
     $this->request->setMethod('POST')->setPost(array('login' => $this->_fixture['login']));
     $this->dispatch("/users/register/");
     $this->assertModule('users');
     $this->assertController('register');
     $this->assertAction('index');
     $user->delete();
 }
예제 #3
0
 /**
  * TODO remove hard code
  *
  */
 function testAuthenticate()
 {
     // guest user login/password (non activated)
     $result = Users_Model_User_Manager::authenticate($this->_fixture['guest']['login'], $this->_fixture['guest']['password']);
     $this->assertFalse($result);
     // blocked user login/password
     $result = Users_Model_User_Manager::authenticate($this->_fixture['blocked']['login'], $this->_fixture['blocked']['password']);
     $this->assertFalse($result);
     // removed login/password
     $result = Users_Model_User_Manager::authenticate($this->_fixture['removed']['login'], $this->_fixture['removed']['password']);
     $this->assertFalse($result);
     // wrong login/password
     $result = Users_Model_User_Manager::authenticate($this->_fixture['admin']['login'], $this->_fixture['admin']['password'] . 'd');
     $this->assertFalse($result);
     // right login/password
     $result = Users_Model_User_Manager::authenticate($this->_fixture['admin']['login'], $this->_fixture['admin']['password']);
     $this->assertTrue($result);
     // chech Zend_Auth
     $this->assertEquals(Users_Model_User::ROLE_ADMIN, Zend_Auth::getInstance()->getIdentity()->role);
 }