public function testToEnglishConversion()
 {
     $biLingualChars = 'Аеrох';
     $english = 'Aerox';
     $this->assertNotEquals($biLingualChars, $english, 'source words should look similar but not really equal');
     $this->assertEquals($english, CharTranslator::toEnglish($biLingualChars), 'bilingual to english chars conversion failed');
 }
 protected function processSubmit(ChainContainer $chain)
 {
     $request = $chain->getRequest();
     $user = $chain->getFrom();
     $lang = $user->getLang();
     $onlineLimitRule = function ($val) {
         $val = (int) $val;
         return $val >= 0 && $val <= 50;
     };
     $aboutRule = function ($val) {
         $len = mb_strlen($val);
         return $len >= 0 && $len <= 1024;
     };
     try {
         $form = (new Form())->import($request)->addRule(PropertiesDAO::NAME, Rules::namePattern(), $lang->getPhrase('InvalidNameFormat'))->addRule(PropertiesDAO::ABOUT, $aboutRule, $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::TIM, Rules::timPattern(), $lang->getPhrase('InvalidTIMFormat'))->addRule(PropertiesDAO::SEX, Rules::sexPattern(), $lang->getPhrase('InvalidSexFormat'))->addRule(PropertiesDAO::CITY, Rules::cityPattern(), $lang->getPhrase('InvalidCityFormat'))->addRule(PropertiesDAO::BIRTH, Rules::birthYears(), $lang->getPhrase('InvalidYearFormat'))->addRule(PropertiesDAO::CENSOR, Rules::notNull(), $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::NOTIFY_VISUAL, Rules::notNull(), $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::NOTIFY_SOUND, Rules::notNull(), $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::LINE_BREAK_TYPE, Rules::notNull(), $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::ONLINE_NOTIFICATION, $onlineLimitRule, $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::IS_SUBSCRIBED, Rules::notNull(), $lang->getPhrase('InvalidField'))->addRule(PropertiesDAO::MESSAGE_ANIMATION_TYPE, Rules::msgAnimationType(), $lang->getPhrase('InvalidField'));
     } catch (WrongRuleNameException $e) {
         RespondError::make($user, ['property' => $lang->getPhrase('InvalidProperty') . ' ' . $e->getMessage()]);
         return;
     }
     if (!$form->validate()) {
         RespondError::make($user, $form->getErrors());
         return;
     }
     $userName = $request[PropertiesDAO::NAME] = strip_tags(trim($request[PropertiesDAO::NAME]));
     if (!$this->checkIfAlreadyRegisteredName(CharTranslator::toEnglish($userName), $user)) {
         return;
     }
     if (!$this->checkIfAlreadyRegisteredName(CharTranslator::toRussian($userName), $user)) {
         return;
     }
     if ($user->isInPrivateChat() || PendingDuals::get()->getUserPosition($user)) {
         $this->forbiddenChangeInDualization($user);
         $this->propertiesResponse($user);
         return;
     }
     $oldName = $user->getProperties()->getName();
     $this->importProperties($user, $request);
     $this->guestsUpdateResponse($user, $oldName);
     $this->propertiesResponse($user);
     ChannelNotifier::notifyOnPendingDuals($user);
 }