EmailActivationFixture::class, ]; } public function testRecoverPassword(): void { $fixture = $this->tester->grabFixture('emailActivations', 'freshPasswordRecovery'); $component = $this->createPartialMock(Component::class, ['terminateSessions']); $component->expects($this->once()) ->method('terminateSessions') ->with($this->callback(fn(Account $account): bool => $account->id === $fixture['account_id']), 0); Yii::$app->set('user', $component); $model = new RecoverPasswordForm([ 'key' => $fixture['key'], 'newPassword' => '12345678', 'newRePassword' => '12345678', ]); $result = $model->recoverPassword(); $this->assertNotNull($result); $this->assertNull($result->getRefreshToken(), 'session was not generated'); $this->assertFalse(EmailActivation::find()->andWhere(['key' => $fixture['key']])->exists()); /** @var Account $account */ $account = Account::findOne($fixture['account_id']); $this->assertTrue($account->validatePassword('12345678')); } }