You are here

protected function TelephoneFormatterFunctionalTest::generateTelephoneField in Telephone Formatter 7

Helper method for telephone field generation.

1 call to TelephoneFormatterFunctionalTest::generateTelephoneField()
TelephoneFormatterFunctionalTest::testTelephoneFieldFallback in tests/TelephoneFormatterFunctionalTest.test
Helper function for testTelephoneField().

File

tests/TelephoneFormatterFunctionalTest.test, line 39

Class

TelephoneFormatterFunctionalTest

Code

protected function generateTelephoneField($settings = array()) {

  // Add the telephone field to the article content type.
  $field_name = 'field_telephone';
  $field = array(
    'field_name' => $field_name,
    'type' => 'telephone',
  );
  field_create_field($field);
  $instance = array(
    'field_name' => $field_name,
    'entity_type' => 'node',
    'bundle' => 'page',
    'label' => 'Telephone Number',
  );
  field_create_instance($instance);
  $instance_info = field_info_instance('node', 'field_telephone', 'page');
  $instance_info['display']['default'] = $settings + array(
    'format' => PhoneNumberFormat::INTERNATIONAL,
    'link' => TRUE,
    'default_country' => NULL,
  );
  field_update_instance($instance_info);
}