You are here

public function MobileNumberFieldTestCase::createMobileNumberNode in Mobile Number 7

Create node with mobile number(s).

1 call to MobileNumberFieldTestCase::createMobileNumberNode()
MobileNumberFieldTestCase::testNumberUniqueness in tests/mobile_number.field.test
Test number validation.

File

tests/mobile_number.field.test, line 135

Class

MobileNumberFieldTestCase
Class for testing mobile_number field.

Code

public function createMobileNumberNode($name, $number, $verified, $verified2 = NULL) {
  $values = array();
  $values["field_{$name}"][LANGUAGE_NONE][0] = array(
    'mobile' => $number,
    'country-code' => 'IL',
  );
  if ($verified) {
    $values["field_{$name}"][LANGUAGE_NONE][0]['verification_code'] = $code = MobileNumber::generateVerificationCode();
    $values["field_{$name}"][LANGUAGE_NONE][0]['verification_token'] = MobileNumber::registerVerificationCode($code, $number);
  }
  if (isset($verified2)) {
    $values["field_{$name}"][LANGUAGE_NONE][1] = array(
      'mobile' => $number,
      'country-code' => 'IL',
    );
    if ($verified2) {
      $values["field_{$name}"][LANGUAGE_NONE][1]['verification_code'] = $code = MobileNumber::generateVerificationCode();
      $values["field_{$name}"][LANGUAGE_NONE][1]['verification_token'] = MobileNumber::registerVerificationCode($code, $number);
    }
  }
  return $this
    ->submitNodeForm($name, $values, $number);
}