You are here

public function SmsFrameworkBrowserTest::testQueueReport in SMS Framework 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/SmsFrameworkBrowserTest.php \Drupal\Tests\sms\Functional\SmsFrameworkBrowserTest::testQueueReport()
  2. 2.1.x tests/src/Functional/SmsFrameworkBrowserTest.php \Drupal\Tests\sms\Functional\SmsFrameworkBrowserTest::testQueueReport()

Tests queue statistics located on Drupal report page.

File

tests/src/Functional/SmsFrameworkBrowserTest.php, line 21

Class

SmsFrameworkBrowserTest
Integration tests for the SMS Framework.

Namespace

Drupal\Tests\sms\Functional

Code

public function testQueueReport() {
  $gateway = $this
    ->createMemoryGateway();

  /** @var \Drupal\sms\Provider\SmsProviderInterface $provider */
  $provider = \Drupal::service('sms.provider');

  /** @var \Drupal\sms\Entity\SmsMessageInterface $sms_message */
  $sms_message = SmsMessage::create();
  $sms_message
    ->setMessage($this
    ->randomString())
    ->addRecipients($this
    ->randomPhoneNumbers());
  for ($i = 0; $i < 2; $i++) {
    $clone = $sms_message
      ->createDuplicate()
      ->setDirection(Direction::INCOMING)
      ->setGateway($gateway);
    $clone
      ->setResult($this
      ->createMessageResult($clone));
    $provider
      ->queue($clone);
  }
  for ($i = 0; $i < 4; $i++) {
    $clone = $sms_message
      ->createDuplicate()
      ->setDirection(Direction::OUTGOING);
    $provider
      ->queue($clone);
  }
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet(Url::fromRoute('system.status'));
  $this
    ->assertRaw('There are 2 messages in the incoming queue.');
  $this
    ->assertRaw('There are 4 messages in the outgoing queue.');
}