public function SmsFrameworkMessageEntityTest::testSaveAndRetrieveSmsMessage in SMS Framework 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/SmsFrameworkMessageEntityTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkMessageEntityTest::testSaveAndRetrieveSmsMessage()
- 2.1.x tests/src/Kernel/SmsFrameworkMessageEntityTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkMessageEntityTest::testSaveAndRetrieveSmsMessage()
Tests saving and retrieval of complete entity.
File
- tests/
src/ Kernel/ SmsFrameworkMessageEntityTest.php, line 299
Class
- SmsFrameworkMessageEntityTest
- Tests SMS message entity.
Namespace
Drupal\Tests\sms\KernelCode
public function testSaveAndRetrieveSmsMessage() {
/** @var \Drupal\sms\Entity\SmsMessageInterface $sms_message */
$sms_message = SmsMessage::create()
->setMessage($this
->randomMachineName(100))
->setSender($this
->randomMachineName())
->setDirection(Direction::OUTGOING)
->addRecipients([
'1234567890',
'2345678901',
]);
$sms_message
->setResult($this
->createMessageResult($sms_message))
->save();
$saved = SmsMessage::load($sms_message
->id());
$this
->assertEquals($sms_message
->getMessage(), $saved
->getMessage());
$this
->assertEquals($sms_message
->getSender(), $saved
->getSender());
$this
->assertEquals($sms_message
->getDirection(), $saved
->getDirection());
$this
->assertEquals($sms_message
->getRecipients(), $saved
->getRecipients());
$this
->assertEquals($sms_message
->getResult()
->getErrorMessage(), $saved
->getResult()
->getErrorMessage());
$this
->assertEquals(count($sms_message
->getReports()), count($saved
->getReports()));
$this
->assertEquals(2, count($sms_message
->getReports()));
}