public function testWhenActivationCodeIsInvalid()
 {
     $activationCode = uniqid();
     $this->activationRepo->expects($this->once())->method('FindUserIdByCode')->with($this->equalTo($activationCode))->will($this->returnValue(null));
     $result = $this->activation->Activate($activationCode);
     $this->assertFalse($result->Activated());
 }
 public function actionActivateAccount($key)
 {
     try {
         $user = new AccountActivation($key);
     } catch (InvalidParamException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
     if ($user->activateAccount()) {
         Yii::$app->session->setFlash('success', 'Активация прошла успешно. <strong>' . Html::encode($user->username) . '</strong> вы теперь с phpNT!!!');
     } else {
         Yii::$app->session->setFlash('error', 'Ошибка активации.');
         Yii::error('Ошибка при активации.');
     }
     return $this->redirect(Url::to(['/main/login']));
 }