You are here

public function SmsSendToPhoneBrowserTest::setUp in SMS Framework 2.1.x

Same name and namespace in other branches
  1. 8 modules/sms_sendtophone/tests/src/Functional/SmsSendToPhoneBrowserTest.php \Drupal\Tests\sms_sendtophone\Functional\SmsSendToPhoneBrowserTest::setUp()
  2. 2.x modules/sms_sendtophone/tests/src/Functional/SmsSendToPhoneBrowserTest.php \Drupal\Tests\sms_sendtophone\Functional\SmsSendToPhoneBrowserTest::setUp()

Overrides SmsFrameworkBrowserTestBase::setUp

File

modules/sms_sendtophone/tests/src/Functional/SmsSendToPhoneBrowserTest.php, line 55

Class

SmsSendToPhoneBrowserTest
Integration tests for the SMS SendToPhone Module.

Namespace

Drupal\Tests\sms_sendtophone\Functional

Code

public function setUp() {
  parent::setUp();

  // Create Basic page and Article node types.
  if ($this->profile != 'standard') {
    $this
      ->drupalCreateContentType([
      'type' => 'page',
      'name' => 'Basic page',
      'display_submitted' => FALSE,
    ]);
    $this
      ->drupalCreateContentType([
      'type' => 'article',
      'name' => 'Article',
    ]);
  }
  $this->gateway = $this
    ->createMemoryGateway([
    'skip_queue' => TRUE,
  ]);
  $this
    ->setFallbackGateway($this->gateway);
  $this->phoneField = FieldStorageConfig::create([
    'entity_type' => 'user',
    'field_name' => mb_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();
}