public function testValidatesUpdateRequest()
 {
     $request = UpdateUserRequest::Example();
     $session = new FakeWebServiceUserSession(123);
     $errors = array('error');
     $this->requestValidator->expects($this->once())->method('ValidateUpdateRequest')->with($this->equalTo(1), $this->equalTo($request))->will($this->returnValue($errors));
     $result = $this->controller->Update(1, $request, $session);
     $this->assertFalse($result->WasSuccessful());
     $this->assertEquals($errors, $result->Errors());
 }
 /**
  * @param int $userId
  * @param UpdateUserRequest $request
  * @param WebServiceUserSession $session
  * @return UserControllerResult
  */
 public function Update($userId, $request, $session)
 {
     $errors = $this->requestValidator->ValidateUpdateRequest($userId, $request);
     if (!empty($errors)) {
         return new UserControllerResult(null, $errors);
     }
     $userService = $this->serviceFactory->CreateAdmin();
     $extraAttributes = array(UserAttribute::Phone => $request->phone, UserAttribute::Organization => $request->organization, UserAttribute::Position => $request->position);
     $customAttributes = array();
     foreach ($request->GetCustomAttributes() as $attribute) {
         $customAttributes[] = new AttributeValue($attribute->attributeId, $attribute->attributeValue);
     }
     $userService->UpdateUser($userId, $request->userName, $request->emailAddress, $request->firstName, $request->lastName, $request->timezone, $extraAttributes);
     $userService->ChangeAttributes($userId, $customAttributes);
     return new UserControllerResult($userId);
 }