You are here

protected function SmsValidWebTest::randomRuleset in SMS Framework 7

Creates a random ruleset.

2 calls to SmsValidWebTest::randomRuleset()
SmsValidWebTest::testSmsValidFunctions in modules/sms_valid/sms_valid.test
Tests the internal sms_valid functions.
SmsValidWebTest::testSmsValidSettingsForm in modules/sms_valid/sms_valid.test
Tests the application of the sms_valid settings form and settings.

File

modules/sms_valid/sms_valid.test, line 252
Contains tests for the functions in sms.module and core sms framework.

Class

SmsValidWebTest
Provides unit tests for SMS Valid validation functions.

Code

protected function randomRuleset() {
  $ruleset = array(
    'prefix' => (string) rand(1, 999),
    'name' => $this
      ->randomName(),
    'dirs_enabled' => 4,
    'iso2' => strtoupper($this
      ->randomName(1) . $this
      ->randomName(1)),
  );

  // Populate random rules.
  for ($i = 0; $i < rand(0, 10); $i++) {
    $ruleset['rules'][rand(1, 99)] = array(
      'allow' => rand(1, 10) > 5,
      'comment' => $this
        ->randomString(),
    );
  }
  return $ruleset;
}