You are here

protected function SmsFrameworkPhoneNumberVerificationTest::setUp in SMS Framework 8

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

Overrides SmsFrameworkKernelBase::setUp

File

tests/src/Kernel/SmsFrameworkPhoneNumberVerificationTest.php, line 68

Class

SmsFrameworkPhoneNumberVerificationTest
Tests Phone Number Provider.

Namespace

Drupal\Tests\sms\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test');
  $this
    ->installEntitySchema('sms_phone_number_verification');
  $this->gateway = $this
    ->createMemoryGateway([
    'skip_queue' => TRUE,
  ]);
  $this
    ->setFallbackGateway($this->gateway);
  $this->phoneNumberVerificationProvider = $this->container
    ->get('sms.phone_number.verification');
  $this->phoneField = FieldStorageConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => Unicode::strtolower($this
      ->randomMachineName()),
    'type' => 'telephone',
  ]);
  $this->phoneField
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
    'field_name' => $this->phoneField
      ->getName(),
  ])
    ->save();
  $this->phoneNumberSettings = PhoneNumberSettings::create();
  $this->phoneNumberSettings
    ->setPhoneNumberEntityTypeId('entity_test')
    ->setPhoneNumberBundle('entity_test')
    ->setFieldName('phone_number', $this->phoneField
    ->getName())
    ->setVerificationMessage($this
    ->randomString())
    ->save();
}