You are here

protected function TfaRecoveryCodeTest::getFixture in Two-factor Authentication (TFA) 8

Helper method to construct the test fixture.

Return value

\Drupal\tfa\Plugin\TfaValidation\TfaRecoveryCode Recovery code.

Throws

\Exception

1 call to TfaRecoveryCodeTest::getFixture()
TfaRecoveryCodeTest::testReadyCodesValidate in tests/src/Unit/Plugin/TfaValidation/TfaRecoveryCodeTest.php
@covers ::ready @covers ::getCodes @covers ::validate

File

tests/src/Unit/Plugin/TfaValidation/TfaRecoveryCodeTest.php, line 98

Class

TfaRecoveryCodeTest
@coversDefaultClass \Drupal\tfa\Plugin\TfaValidation\TfaRecoveryCode

Namespace

Drupal\Tests\tfa\Unit\Plugin\TfaValidation

Code

protected function getFixture() {

  // The plugin calls out to the global \Drupal object, so mock that here.
  $this->configFactory
    ->get('tfa.settings')
    ->willReturn($this->tfaSettings
    ->reveal());
  $container = new ContainerBuilder();
  $container
    ->set('config.factory', $this->configFactory
    ->reveal());
  $container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  \Drupal::setContainer($container);
  return new TfaRecoveryCode($this->configuration, 'tfa_recovery_code', [], $this->userData
    ->reveal(), $this->encryptionProfileManager
    ->reveal(), $this->encryptionService
    ->reveal(), $container
    ->get('config.factory'));
}