public function testRegister()
 {
     $this->model = new RegistrationForm();
     $this->model->setAttributes(['email' => '*****@*****.**', 'username' => 'foobar', 'password' => 'foobar']);
     /** @var User $user */
     verify($this->model->register())->true();
     $user = User::findOne(['email' => '*****@*****.**']);
     verify('$user is instance of User', $user instanceof User)->true();
     verify('email is valid', $user->email)->equals($this->model->email);
     verify('username is valid', $user->username)->equals($this->model->username);
     verify('password is valid', Password::validate($this->model->password, $user->password_hash))->true();
     $token = Token::findOne(['user_id' => $user->id, 'type' => Token::TYPE_CONFIRMATION]);
     verify($token)->notNull();
     $mock = $this->getMock(RegistrationForm::className(), ['validate']);
     $mock->expects($this->once())->method('validate')->will($this->returnValue(false));
     verify($mock->register())->false();
 }