You are here

public function SmsFrameworkUserAccountRegistrationServiceTest::testUnrecognisedCreateUser 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::testUnrecognisedCreateUser()
  2. 2.1.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::testUnrecognisedCreateUser()

Test user is created if a unrecognised phone number is used as sender.

File

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

Class

SmsFrameworkUserAccountRegistrationServiceTest
Tests account registration.

Namespace

Drupal\Tests\sms_user\Kernel

Code

public function testUnrecognisedCreateUser() {
  $this
    ->config('sms_user.settings')
    ->set('account_registration.unrecognized_sender.status', 1)
    ->set('account_registration.unrecognized_sender.reply.status', 1)
    ->save();
  $sender_number = '+123123123';
  $this
    ->sendIncomingMessage($sender_number, $this
    ->randomString());
  $user = $this
    ->getLastUser();
  $this
    ->assertTrue($user instanceof UserInterface, 'One user created.');
  $this
    ->assertEquals($sender_number, $user->{$this->phoneField
    ->getName()}->value, 'Phone number associated');
}