You are here

protected function FeaturesExtraTestCase::revertComponents in Features Extra 7

Test if components can be reverted and that overrides are detected.

2 calls to FeaturesExtraTestCase::revertComponents()
FeaturesExtraBlockTestCase::testBlockRevert in tests/fe_block.test
Test if custom blocks can be reverted and that overrides are detected.
FeaturesExtraNodequeueTestCase::testNodequeueRevert in tests/fe_nodequeue.test
Test if nodequeues can be reverted and that overrides are detected.

File

tests/features_extra_test_case.test, line 26
Base class for Features Extra tests.

Class

FeaturesExtraTestCase
@file Base class for Features Extra tests.

Code

protected function revertComponents($components = array()) {
  module_load_include('inc', 'features', 'features.export');
  foreach ($components as $component) {

    // Ensure that the component is in its default state initially.
    $states = features_get_component_states(array(
      'features_extra_test',
    ), FALSE, TRUE);
    $this
      ->assertTrue($states['features_extra_test'][$component] === FEATURES_DEFAULT, t('@component state: Default.', array(
      '@component' => $component,
    )));

    // Override component and test that Features detects the override.
    $callback = "override_{$component}";
    $this
      ->{$callback}();
    $states = features_get_component_states(array(
      'features_extra_test',
    ), FALSE, TRUE);
    $this
      ->assertTrue($states['features_extra_test'][$component] === FEATURES_OVERRIDDEN, t('@component state: Overridden.', array(
      '@component' => $component,
    )));
  }

  // Revert component and ensure that component has reverted.
  features_revert(array(
    'features_extra_test' => $components,
  ));
  foreach ($components as $component) {
    $states = features_get_component_states(array(
      'features_extra_test',
    ), FALSE, TRUE);
    $this
      ->assertTrue($states['features_extra_test'][$component] === FEATURES_DEFAULT, t('@component reverted successfully.', array(
      '@component' => $component,
    )));
  }
}