function SmsActionsUnitTest::testDiscriminatorValidation in SMS Framework 7
File
- modules/
sms_actions/ sms_actions.test, line 210 - Contains tests for the functions in sms_action.module and actions integration.
Class
- SmsActionsUnitTest
- Provides unit tests for the sms_action module.
Code
function testDiscriminatorValidation() {
// Testbot is not seeing the module file.
require_once dirname(__FILE__) . '/sms_actions.module';
$pass = array(
'test1',
'test-2',
'test3',
);
foreach ($pass as $machine_name) {
$form_state['values']['discriminator'] = $machine_name;
sms_actions_edit_command_form_validate(array(), $form_state);
$errors = form_get_errors();
$this
->assertFalse($errors['discriminator'], 'Valid command name "' . $machine_name . '" passed validation');
form_clear_error();
}
$fail = array(
'test 1',
'test_2',
'Test3',
);
foreach ($fail as $machine_name) {
$form_state['values']['discriminator'] = $machine_name;
sms_actions_edit_command_form_validate(array(), $form_state);
$errors = form_get_errors();
$this
->assertTrue($errors['discriminator'], 'Invalid command name "' . $machine_name . '" failed validation');
form_clear_error();
}
}