public function FeaturesUserTestCase::test in Features 7
Same name and namespace in other branches
- 6 tests/features.test \FeaturesUserTestCase::test()
- 7.2 tests/features.test \FeaturesUserTestCase::test()
Run test.
File
- tests/
features.test, line 44
Class
- FeaturesUserTestCase
- User permission component tests for Features
Code
public function test() {
module_load_include('inc', 'features', 'features.export');
$components = array_filter(array(
'field' => 'field',
'filter' => 'filter',
'image' => 'image',
'node' => 'node',
'user_permission' => 'user',
'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,
)));
}
}