You are here

protected function SmsFrameworkUserAccountRegistrationServiceTest::setUp in SMS Framework 8

Same name and namespace in other branches
  1. 2.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::setUp()
  2. 2.1.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::setUp()

Overrides SmsFrameworkKernelBase::setUp

File

modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php, line 79

Class

SmsFrameworkUserAccountRegistrationServiceTest
Tests account registration.

Namespace

Drupal\Tests\sms_user\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installConfig('sms_user');
  $this->accountRegistration = $this->container
    ->get('sms_user.account_registration');
  $this->smsProvider = $this->container
    ->get('sms.provider');
  $this->gateway = $this
    ->createMemoryGateway([
    'skip_queue' => TRUE,
  ]);
  $this
    ->setFallbackGateway($this->gateway);
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('sms');
  $this
    ->installEntitySchema('sms_result');
  $this
    ->installEntitySchema('sms_report');
  $this
    ->installEntitySchema('sms_phone_number_verification');
  $this->phoneField = FieldStorageConfig::create([
    'entity_type' => 'user',
    'field_name' => Unicode::strtolower($this
      ->randomMachineName()),
    'type' => 'telephone',
  ]);
  $this->phoneField
    ->save();
  FieldConfig::create([
    'entity_type' => 'user',
    'bundle' => 'user',
    'field_name' => $this->phoneField
      ->getName(),
  ])
    ->save();
  $this->phoneNumberSettings = PhoneNumberSettings::create();
  $this->phoneNumberSettings
    ->setPhoneNumberEntityTypeId('user')
    ->setPhoneNumberBundle('user')
    ->setFieldName('phone_number', $this->phoneField
    ->getName())
    ->setVerificationMessage($this
    ->randomString())
    ->save();
  $this
    ->config('system.mail')
    ->set('interface.default', 'test_mail_collector')
    ->save();
  $this
    ->config('user.settings')
    ->set('notify.register_no_approval_required', TRUE)
    ->save();
}