You are here

public function SmsFrameworkPhoneNumberAdminTest::testPhoneNumberList in SMS Framework 2.x

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

Tests phone number list.

File

tests/src/Functional/SmsFrameworkPhoneNumberAdminTest.php, line 51

Class

SmsFrameworkPhoneNumberAdminTest
Tests phone number administration user interface.

Namespace

Drupal\Tests\sms\Functional

Code

public function testPhoneNumberList() {
  $this
    ->drupalGet('admin/config/smsframework/phone_number');
  $this
    ->assertRaw(t('No phone number settings found.'));
  $this
    ->assertLinkByHref('admin/config/smsframework/phone_number/add');

  // Ensure statistics are appearing on list.
  $this
    ->createPhoneNumberSettings('entity_test', 'entity_test');
  $entity = EntityTest::create();
  $quantity = [
    6,
    2,
    4,
  ];

  /** @var \Drupal\sms\Entity\PhoneNumberVerificationInterface $verification */

  // Expired.
  for ($j = 0; $j < $quantity[0]; $j++) {
    $verification = PhoneNumberVerification::create();
    $verification
      ->setStatus(FALSE)
      ->set('created', 0)
      ->setEntity($entity)
      ->save();
  }

  // Verified.
  for ($j = 0; $j < $quantity[1]; $j++) {
    $verification = PhoneNumberVerification::create();
    $verification
      ->setStatus(TRUE)
      ->setEntity($entity)
      ->save();
  }

  // Unverified.
  for ($j = 0; $j < $quantity[2]; $j++) {
    $verification = PhoneNumberVerification::create();
    $verification
      ->setStatus(FALSE)
      ->setEntity($entity)
      ->save();
  }
  $this
    ->drupalGet('admin/config/smsframework/phone_number');
  $this
    ->assertRaw('<td>entity_test</td>
                      <td>' . $quantity[0] . '</td>
                      <td>' . $quantity[1] . '</td>
                      <td>' . ($quantity[0] + $quantity[2]) . '</td>
                      <td>' . array_sum($quantity) . '</td>');
}