You are here

protected function SmsFrameworkPhoneNumberTest::countVerificationCodes in SMS Framework 2.1.x

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

Count verification codes in database.

Parameters

\Drupal\Core\Entity\EntityInterface|null $entity: The entity to count verification codes for, or NULL to count all codes.

Return value

int Count number of verification codes.

2 calls to SmsFrameworkPhoneNumberTest::countVerificationCodes()
SmsFrameworkPhoneNumberTest::testPhoneNumberVerificationCreated in tests/src/Functional/SmsFrameworkPhoneNumberTest.php
Test verification code creation on entity postsave.
SmsFrameworkPhoneNumberTest::testPhoneNumberVerificationDeleted in tests/src/Functional/SmsFrameworkPhoneNumberTest.php
Ensure phone number verification are deleted.

File

tests/src/Functional/SmsFrameworkPhoneNumberTest.php, line 106

Class

SmsFrameworkPhoneNumberTest
General phone number verification tests.

Namespace

Drupal\Tests\sms\Functional

Code

protected function countVerificationCodes(EntityInterface $entity = NULL) {
  $query = \Drupal::entityTypeManager()
    ->getStorage('sms_phone_number_verification')
    ->getQuery();
  if ($entity) {
    $query
      ->condition('entity__target_type', $entity
      ->getEntityTypeId());
    $query
      ->condition('entity__target_id', $entity
      ->id());
  }
  return $query
    ->count()
    ->execute();
}