public function SmsFrameworkUserAccountRegistrationServiceTest::testErrorBuilder in SMS Framework 8
Same name and namespace in other branches
- 2.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::testErrorBuilder()
- 2.1.x modules/sms_user/tests/src/Kernel/SmsFrameworkUserAccountRegistrationServiceTest.php \Drupal\Tests\sms_user\Kernel\SmsFrameworkUserAccountRegistrationServiceTest::testErrorBuilder()
Test error builder.
@covers ::buildError
File
- modules/
sms_user/ tests/ src/ Kernel/ SmsFrameworkUserAccountRegistrationServiceTest.php, line 456
Class
- SmsFrameworkUserAccountRegistrationServiceTest
- Tests account registration.
Namespace
Drupal\Tests\sms_user\KernelCode
public function testErrorBuilder() {
$failure_prefix = 'foo: ';
$this
->config('sms_user.settings')
->set('account_registration.incoming_pattern.status', 1)
->set('account_registration.incoming_pattern.incoming_messages.0', "[username] [email]")
->set('account_registration.incoming_pattern.reply.status', 1)
->set('account_registration.incoming_pattern.reply.message_failure', $failure_prefix . '[error]')
->save();
$username = $this
->randomMachineName();
$email = 'email@domain.tld';
User::create([
'name' => $username,
'mail' => $email,
])
->save();
$message = "{$username} " . $this
->randomMachineName();
$this
->sendIncomingMessage('+123123123', $message);
$expected_error = 'The username ' . $username . ' is already taken. This value is not a valid email address. ';
$actual = $this
->getLastTestMessage($this->gateway)
->getMessage();
$this
->assertEquals($failure_prefix . $expected_error, $actual);
}