public function FeaturesUserTestCase::test in Features 7.2
Same name and namespace in other branches
- 6 tests/features.test \FeaturesUserTestCase::test()
- 7 tests/features.test \FeaturesUserTestCase::test()
Run test.
File
- tests/
features.test, line 58 - Contains test classes for features module.
Class
- FeaturesUserTestCase
- User permission component tests for Features.
Code
public function test() {
module_load_include('inc', 'features', 'features.export');
$components = array_filter(array(
/* @see _test_field_instance() */
'field_instance' => 'field',
/* @see _test_filter() */
'filter' => 'filter',
/* @see _test_image() */
'image' => 'image',
/* @see _test_node() */
'node' => 'node',
/* @see _test_user_permission() */
'user_permission' => 'user',
/* @see _test_views_view() */
'views_view' => 'views',
), 'module_exists');
foreach (array_keys($components) as $component) {
$callback = "_test_{$component}";
// Ensure that the component/default is properly available.
$object = $this
->{$callback}('load');
$this
->assertTrue(!empty($object), t('@component present.', array(
'@component' => $component,
)));
// Ensure that the component is defaulted.
$states = features_get_component_states(array(
'features_test',
), FALSE, TRUE);
$this
->assertTrue($states['features_test'][$component] === FEATURES_DEFAULT, t('@component state: Default.', array(
'@component' => $component,
)));
// Override component and test that Features detects the override.
$this
->{$callback}('override', $this);
$states = features_get_component_states(array(
'features_test',
), FALSE, TRUE);
$this
->assertTrue($states['features_test'][$component] === FEATURES_OVERRIDDEN, t('@component state: Overridden.', array(
'@component' => $component,
)));
}
// Revert component and ensure that component has reverted.
// Do this in separate loops so we only have to run
// drupal_flush_all_caches() once.
foreach (array_keys($components) as $component) {
features_revert(array(
'features_test' => array(
$component,
),
));
}
drupal_flush_all_caches();
foreach (array_keys($components) as $component) {
// Reload so things like Views can clear it's cache.
$this
->{$callback}('load');
$states = features_get_component_states(array(
'features_test',
), FALSE, TRUE);
$this
->assertTrue($states['features_test'][$component] === FEATURES_DEFAULT, t('@component reverted.', array(
'@component' => $component,
)));
}
}