public function SmsFrameworkWebTest::testNumberValidation in SMS Framework 7
Tests basic number validation.
File
- tests/
sms.module.test, line 88 - Contains tests for the functions in sms.module and core sms framework.
Class
- SmsFrameworkWebTest
- Provides integration tests for the SMS Framework.
Code
public function testNumberValidation() {
$test_numbers = array(
'1234567890' => true,
'123458767890' => true,
'389427-9238' => true,
'=-,x2-4n292' => true,
';ajklf a/s,MFA' => false,
'] W[OPQIRW' => false,
'9996789065' => true,
'1234567890987654' => true,
);
// Test validation with default gateway (log).
foreach ($test_numbers as $number => $valid) {
$result = sms_validate_number($number);
$this
->assertEqual($valid, empty($result), 'Number validation ok for ' . $number);
}
// Update the expected results for sms_test_gateway.
$test_numbers = array(
'389427-9238' => false,
'=-,x2-4n292' => false,
'9996789065' => false,
'1234567890987654' => false,
) + $test_numbers;
// Test validation with test gateway that has custom validation.
foreach ($test_numbers as $number => $valid) {
$result = sms_validate_number($number, array(
'gateway' => 'test',
));
$this
->assertEqual($valid, empty($result), 'Number validation ok for ' . $number);
}
}