You are here

public function SmsFrameworkUserAccountRegistrationServiceTest::testIncomingPatternUserCreated in SMS Framework 2.x

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

Test user is created from a incoming pattern message.

File

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

Class

SmsFrameworkUserAccountRegistrationServiceTest
Tests account registration.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testIncomingPatternUserCreated() {
  $this
    ->config('sms_user.settings')
    ->set('account_registration.incoming_pattern.status', 1)
    ->set('account_registration.incoming_pattern.reply.status', 1)
    ->save();
  $username = $this
    ->randomMachineName();
  $email = 'email@email.com';
  $sender_number = '+123123123';
  $message = "E " . $email . "\nU " . $username;
  $this
    ->sendIncomingMessage($sender_number, $message);
  $user = user_load_by_name($username);
  $this
    ->assertTrue($user instanceof UserInterface, 'User was created');
  $this
    ->assertEquals($username, $user
    ->getAccountName());
  $this
    ->assertEquals($email, $user
    ->getEmail());
  $this
    ->assertEquals($sender_number, $user->{$this->phoneField
    ->getName()}->value, 'Phone number associated');
}