1 field_permission_example.test public GenericFieldTest::runTestGenericFieldInfo()

Verify that all required fields are specified in hook_field_info().

The full list is label, description, settings, instance_settings, default_widget, default_formatter, no_ui.

Some are optional, and we won't check for those.

In a sane world, this would be a unit test, rather than a web test, but module_implements is unavailable to us in unit tests.

See also



modules/examples/field_permission_example/field_permission_example.test, line 86
Tests for Field Permission Example.


A generic field testing class.


public function runTestGenericFieldInfo() {
  $field_types = $this->getFieldTypes();
  $module = $this->getModule();
  $info_keys = array(
  // We don't want to use field_info_field_types()
  // because there is a hook_field_info_alter().
  // We're testing the module here, not the rest of
  // the system. So invoke hook_field_info() ourselves.
  $modules = module_implements('field_info');
  $this->assertTrue(in_array($module, $modules), 
  'Module ' . $module . ' implements hook_field_info()');

  foreach ($field_types as $field_type) {
    $field_info = module_invoke($module, 'field_info');
    'Module ' . $module . ' defines field type ' . $field_type);
    $field_info = $field_info[$field_type];
    foreach ($info_keys as $key) {
      $field_type . "'s " . $key . ' is set.'