public function setUp()
 {
     parent::setUp();
     $this->controller = $this->login->loadController('Register');
     $this->user = $this->modx->newObject('modUser');
     $this->user->fromArray(array('id' => 12345678, 'username' => 'unit.test.user', 'password' => md5('a test password'), 'cachepwd' => '', 'class_key' => 'modUser', 'active' => false, 'hash_class' => 'hashing.modMD5', 'salt' => '', 'primary_group' => 1));
     $_POST = array('username' => 'unit.test.user', 'password' => 'a test password', 'password_confirm' => 'a test password', 'email' => LoginTestHarness::$properties['email'], 'nospam' => '', 'submitVar' => 'unit-test-register-btn');
     $this->controller->setProperties(array('activation' => true, 'activationResourceId' => 1, 'activationEmailSubject' => 'Login Unit Test Activation Email', 'moderatedResourceId' => 1, 'preHooks' => '', 'postHooks' => '', 'submitVar' => 'unit-test-register-btn', 'submittedResourceId' => 1, 'usergroups' => '', 'validate' => 'nospam:blank'));
     $this->controller->loadDictionary();
 }
 /**
  * Setup the user data and create the user/profile objects
  *
  * @return void
  */
 public function setUserFields()
 {
     $fields = $this->dictionary->toArray();
     /* allow overriding of class key */
     if (empty($fields['class_key'])) {
         $fields['class_key'] = 'modUser';
     }
     $fields = $this->filterAllowedFields($fields);
     /* set user and profile */
     $this->user->fromArray($fields);
     $this->user->set('username', $fields[$this->controller->getProperty('usernameField', 'username')]);
     $this->user->set('active', 0);
     $version = $this->modx->getVersionData();
     /* 2.1.x+ */
     if (version_compare($version['full_version'], '2.1.0-rc1') >= 0) {
         $this->user->set('password', $fields[$this->controller->getProperty('passwordField', 'password')]);
     } else {
         /* 2.0.x */
         $this->user->set('password', md5($fields[$this->controller->getProperty('passwordField', 'password')]));
     }
     $this->profile->fromArray($fields);
     $this->profile->set('email', $this->dictionary->get($this->controller->getProperty('emailField', 'email')));
     $this->user->addOne($this->profile, 'Profile');
     /* add user groups, if set */
     $userGroupsField = $this->controller->getProperty('usergroupsField', '');
     $userGroups = !empty($userGroupsField) && array_key_exists($userGroupsField, $fields) ? $fields[$userGroupsField] : array();
     $this->setUserGroups($userGroups);
 }
 public function setUp()
 {
     parent::setUp();
     $this->user = $this->modx->newObject('modUser');
     $this->user->fromArray(array('id' => 12345678, 'username' => 'unit.test.user', 'password' => md5('a test password'), 'cachepwd' => '', 'class_key' => 'modUser', 'active' => false, 'hash_class' => 'hashing.modMD5', 'salt' => '', 'primary_group' => 1, 'email' => LoginTestHarness::$properties['email']));
     $this->profile = $this->modx->newObject('modUserProfile');
     $this->profile->fromArray(array('internalKey' => 12345678, 'email' => LoginTestHarness::$properties['email'], 'blocked' => false));
     /** @var modUserGroup $userGroup */
     $userGroup = $this->modx->newObject('modUserGroup');
     $userGroup->fromArray(array('name' => 'UnitTest UserGroup 1'));
     $userGroup->save();
     $userGroup = $this->modx->newObject('modUserGroup');
     $userGroup->fromArray(array('name' => 'UnitTest UserGroup 2'));
     $userGroup->save();
     $_POST = array('username' => 'unit.test.user', 'password' => 'a test password', 'email' => '*****@*****.**', 'nospam' => '', 'submitVar' => 'unit-test-register-btn');
     $this->controller = $this->login->loadController('Register');
     $this->controller->initialize();
     $this->controller->setProperties(array('activation' => true, 'activationResourceId' => 1, 'activationEmailSubject' => 'Login Unit Test Activation Email', 'moderatedResourceId' => 1, 'preHooks' => '', 'postHooks' => '', 'submitVar' => 'unit-test-register-btn', 'submittedResourceId' => 1, 'usergroups' => '', 'validate' => 'nospam:blank'));
     $this->controller->loadDictionary();
     $this->processor = $this->controller->loadProcessor('Register');
     $this->processor->user =& $this->user;
     $this->processor->profile =& $this->profile;
 }
Esempio n. 4
0
 public function setUp()
 {
     parent::setUp();
     $this->user = $this->modx->newObject('modUser');
     $this->user->fromArray(array('id' => 123456, 'username' => 'unit-test-user', 'password' => md5('boogles'), 'cachepwd' => '', 'class_key' => 'modUser', 'active' => true, 'remote_key' => '', 'remote_data' => array(), 'hash_class' => 'hashing.modMD5', 'salt' => '', 'primary_group' => 1), '', true, true);
 }