You are here

public function SmsFrameworkUserSettingsTest::testSettingsFormValidationFail in SMS Framework 2.x

Same name and namespace in other branches
  1. 8 modules/sms_user/tests/src/Functional/SmsFrameworkUserSettingsTest.php \Drupal\Tests\sms_user\Functional\SmsFrameworkUserSettingsTest::testSettingsFormValidationFail()
  2. 2.1.x modules/sms_user/tests/src/Functional/SmsFrameworkUserSettingsTest.php \Drupal\Tests\sms_user\Functional\SmsFrameworkUserSettingsTest::testSettingsFormValidationFail()

Tests saving form with invalid values.

File

modules/sms_user/tests/src/Functional/SmsFrameworkUserSettingsTest.php, line 104

Class

SmsFrameworkUserSettingsTest
Tests SMS User settings user interface.

Namespace

Drupal\Tests\sms_user\Functional

Code

public function testSettingsFormValidationFail() {

  // End time < start time.
  $edit = [
    'active_hours[days][wednesday][start]' => 10,
    'active_hours[days][wednesday][end]' => 9,
  ];
  $this
    ->drupalPostForm(Url::fromRoute('sms_user.options'), $edit, 'Save configuration');
  $this
    ->assertRaw('End time must be greater than start time.');

  // Active hours enabled but no days.
  $edit = [
    'active_hours[status]' => TRUE,
    'active_hours[days][wednesday][start]' => -1,
    'active_hours[days][wednesday][end]' => 24,
  ];
  $this
    ->drupalPostForm(Url::fromRoute('sms_user.options'), $edit, 'Save configuration');
  $this
    ->assertRaw('If active hours hours are enabled there must be at least one enabled day.');
}