public function FeaturesUserTestCase::test in Features 6
Same name and namespace in other branches
- 7.2 tests/features.test \FeaturesUserTestCase::test()
- 7 tests/features.test \FeaturesUserTestCase::test()
Run test.
File
- tests/
features.test, line 48
Class
- FeaturesUserTestCase
- User permission component tests for Features
Code
public function test() {
module_load_include('inc', 'features', 'features.export');
$components = array_filter(array(
'content' => 'content',
// 'context' => 'context', // @TODO write tests for context.
'fieldgroup' => 'fieldgroup',
'filter' => 'filter',
'imagecache' => 'imagecache',
'node' => 'node',
'user_permission' => 'user',
'views' => 'views',
), 'module_exists');
foreach (array_keys($components) as $component) {
$callback = "_test_{$component}";
// Ensure that the component/default is properly available.
$object = $this
->{$callback}('load', $id);
$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 ($components as $component) {
features_revert(array(
'features_test' => array(
$component,
),
));
}
drupal_flush_all_caches();
foreach ($components as $component) {
$states = features_get_component_states(array(
'features_test',
), FALSE, TRUE);
$this
->assertTrue($states['features_test'][$component] === FEATURES_DEFAULT, t('@component reverted.', array(
'@component' => $component,
)));
}
}