SmsFrameworkUserTest.php in SMS Framework 2.x
File
modules/sms_user/tests/src/Kernel/SmsFrameworkUserTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\sms_user\Kernel;
use Drupal\Tests\sms\Kernel\SmsFrameworkKernelBase;
use Drupal\sms\Entity\SmsMessage;
use Drupal\sms\Entity\PhoneNumberSettings;
use Drupal\sms\Direction;
class SmsFrameworkUserTest extends SmsFrameworkKernelBase {
public static $modules = [
'system',
'sms',
'sms_user',
'sms_test_gateway',
'user',
'telephone',
'dynamic_entity_reference',
'field',
];
protected $smsProvider;
protected $gateway;
protected function setUp() {
parent::setUp();
$this
->installSchema('system', [
'sequences',
]);
$this
->installConfig('sms_user');
$this
->installEntitySchema('user');
$this
->installEntitySchema('sms');
$this
->installEntitySchema('sms_phone_number_verification');
$this->smsProvider = $this->container
->get('sms.provider');
$this->gateway = $this
->createMemoryGateway([
'skip_queue' => TRUE,
]);
$this
->setFallbackGateway($this->gateway);
}
public function testAccountRegistrationNoPhoneSettings() {
$this
->config('sms_user.settings')
->set('account_registration.unrecognized_sender.status', 1)
->set('account_registration.unrecognized_sender.reply.status', 1)
->save();
$message = $this
->randomString();
$incoming = SmsMessage::create()
->setSenderNumber('+123')
->setDirection(Direction::INCOMING)
->setMessage($message)
->addRecipients($this
->randomPhoneNumbers(1))
->setGateway($this->gateway);
$incoming
->setResult($this
->createMessageResult($incoming));
$this->smsProvider
->queue($incoming);
$this
->assertEquals($message, sms_test_gateway_get_incoming()['message']);
$this
->assertNull(PhoneNumberSettings::load('user.user'), 'No phone numbser settings for user.user.');
}
}