function FieldCrudTestCase::_testActiveHelper
7.x field.test | FieldCrudTestCase::_testActiveHelper($field_definition, $modules) |
Helper function for testActive().
Test dependency between a field and a set of modules.
Parameters
$field_definition: A field definition.
$modules: An aray of module names. The field will be tested to be inactive as long as any of those modules is disabled.
1 call to FieldCrudTestCase::_testActiveHelper()
- FieldCrudTestCase::testActive in drupal-7.x/
modules/ field/ tests/ field.test - Test that fields are properly marked active or inactive.
File
- drupal-7.x/
modules/ field/ tests/ field.test, line 2734 - Tests for field.module.
Class
Code
function _testActiveHelper($field_definition, $modules) {
$field_name = $field_definition['field_name'];
// Read the field.
$field = field_read_field($field_name);
$this->assertTrue($field_definition <= $field, 'The field was properly read.');
module_disable($modules, FALSE);
$fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE));
$this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, 'The field is properly read when explicitly fetching inactive fields.');
// Re-enable modules one by one, and check that the field is still inactive
// while some modules remain disabled.
while ($modules) {
$field = field_read_field($field_name);
$this->assertTrue(empty($field), format_string('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules))));
$module = array_shift($modules);
module_enable(array($module), FALSE);
}
// Check that the field is active again after all modules have been
// enabled.
$field = field_read_field($field_name);
$this->assertTrue($field_definition <= $field, 'The field was was marked active.');
}