Example #1
0
 public function testSynchronizeUpdatesExistingUser()
 {
     $userId = 111;
     $username = '******';
     $email = 'em';
     $fname = 'fn';
     $lname = 'ln';
     $phone = 'ph';
     $inst = 'or';
     $title = 'title';
     $encryptedPassword = $this->fakeEncryption->_Encrypted;
     $salt = $this->fakeEncryption->_Salt;
     $groups = array(new UserGroup(1, '1'), new UserGroup(2, '2'));
     $updatedUser = new User();
     $updatedUser->ChangeGroups($groups);
     $this->userRepository->expects($this->once())->method('UserExists')->with($this->equalTo($email), $this->equalTo($username))->will($this->returnValue($userId));
     $this->userRepository->expects($this->once())->method('LoadByUsername')->with($this->equalTo($username))->will($this->returnValue($updatedUser));
     $this->userRepository->expects($this->once())->method('Update')->with($this->equalTo($updatedUser))->will($this->returnValue($updatedUser));
     $user = new AuthenticatedUser($username, $email, $fname, $lname, 'password', 'en_US', 'UTC', $phone, $inst, $title, $groups);
     $expectedCommand = new UpdateUserFromLdapCommand($username, $email, $fname, $lname, $encryptedPassword, $salt, $phone, $inst, $title);
     $this->registration->Synchronize($user);
     $this->assertTrue($this->db->ContainsCommand($expectedCommand));
 }