You are here

protected function SmsFrameworkVerificationMaintenanceTest::setUp in SMS Framework 2.1.x

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

Overrides SmsFrameworkKernelBase::setUp

File

tests/src/Kernel/SmsFrameworkVerificationMaintenanceTest.php, line 45

Class

SmsFrameworkVerificationMaintenanceTest
Tests verification maintenance executed during cron.

Namespace

Drupal\Tests\sms\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test');
  $this
    ->installEntitySchema('sms_phone_number_verification');
  $this->phoneField = FieldStorageConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => mb_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())
    ->setPurgeVerificationPhoneNumber(FALSE)
    ->setVerificationCodeLifetime(3600)
    ->setVerificationMessage($this
    ->randomString())
    ->save();
  $gateway = $this
    ->createMemoryGateway([
    'skip_queue' => TRUE,
  ]);
  $this
    ->setFallbackGateway($gateway);
  $this->testEntity = $this
    ->createEntityWithPhoneNumber($this->phoneNumberSettings, [
    '+123123123',
  ]);
}