public function SmsFrameworkPhoneNumberProviderTest::testGetPhoneNumbersVerified in SMS Framework 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/SmsFrameworkPhoneNumberProviderTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkPhoneNumberProviderTest::testGetPhoneNumbersVerified()
- 2.1.x tests/src/Kernel/SmsFrameworkPhoneNumberProviderTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkPhoneNumberProviderTest::testGetPhoneNumbersVerified()
Tests phone numbers.
@covers ::getPhoneNumbers
File
- tests/
src/ Kernel/ SmsFrameworkPhoneNumberProviderTest.php, line 128
Class
- SmsFrameworkPhoneNumberProviderTest
- Tests Phone Number Provider.
Namespace
Drupal\Tests\sms\KernelCode
public function testGetPhoneNumbersVerified() {
$phone_numbers_all = [
'+123123123',
'+456456456',
];
// Test zero, one, multiple phone numbers.
for ($i = 0; $i < 3; $i++) {
$phone_numbers = array_slice($phone_numbers_all, 0, $i);
$entity = $this
->createEntityWithPhoneNumber($this->phoneNumberSettings, $phone_numbers);
// Ensures test verifications don't leak between entities. array_values()
// resets array keys since they are not important, assertEquals() normally
// asserts keys.
$phone_number_verified = array_values(array_slice($phone_numbers, 0, 1, TRUE));
$phone_number_unverified = array_values(array_slice($phone_numbers, 1, $i, TRUE));
// Verify first phone number.
if (!empty($phone_number_verified)) {
$this
->verifyPhoneNumber($entity, reset($phone_number_verified));
}
$return = $this->phoneNumberProvider
->getPhoneNumbers($entity, NULL);
$this
->assertEquals($phone_numbers, $return);
$return = $this->phoneNumberProvider
->getPhoneNumbers($entity, FALSE);
$this
->assertEquals($phone_number_unverified, $return, $entity
->id());
$return = $this->phoneNumberProvider
->getPhoneNumbers($entity, TRUE);
$this
->assertEquals($phone_number_verified, $return);
}
}