SmsFrameworkGatewayPluginTest.php in SMS Framework 2.x
File
tests/src/Kernel/SmsFrameworkGatewayPluginTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\sms\Kernel;
use Drupal\sms\Entity\SmsMessage;
use Drupal\sms\Direction;
class SmsFrameworkGatewayPluginTest extends SmsFrameworkKernelBase {
public static $modules = [
'sms',
'sms_test',
'sms_test_gateway',
'field',
'telephone',
'dynamic_entity_reference',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('sms');
$this
->installEntitySchema('sms_result');
$this
->installEntitySchema('sms_report');
$this->smsProvider = $this->container
->get('sms.provider');
}
public function testIncomingEvent() {
$gateway = $this
->createMemoryGateway()
->setSkipQueue(TRUE);
$gateway
->save();
$sms_message = SmsMessage::create()
->setDirection(Direction::INCOMING)
->setMessage($this
->randomString())
->addRecipients($this
->randomPhoneNumbers())
->setGateway($gateway);
$sms_message
->setResult($this
->createMessageResult($sms_message));
$this->smsProvider
->queue($sms_message);
$this
->assertCount(1, \Drupal::state()
->get('sms_test_gateway.memory.incoming'));
}
}