public function CustomBreadcrumbsFeaturesIntegrationTestCase::testFeaturesIntegration in Custom Breadcrumbs Features 7.2
1) By default, crumbs are in default state in Features. 2) If we modify a crumb, its state becomes override. 3) If we revert the feature, the crumb loses its modifications.
File
- tests/
features_integration.test, line 42 - Test that custom_breadcrumbs_features provides custom_breadcrumbs with features integration.
Class
- CustomBreadcrumbsFeaturesIntegrationTestCase
- Test that Custom Breadcrumbs can be exported and rebuilt using Features.
Code
public function testFeaturesIntegration() {
module_enable(array(
'custom_breadcrumbs_features_test',
));
// Run a features rebuild to ensure our feature is fully installed.
features_rebuild();
module_load_include('inc', 'features', 'features.export');
// Crumbs featurized in custom_breadcrumbs_features_test, keyed by type.
$machine_names = array(
'custom_breadcrumb' => 'page',
'custom_breadcrumbsapi' => 'maintenance_page',
'custom_breadcrumbs_panels' => 'panel',
'custom_breadcrumbs_paths' => 'admin',
'custom_breadcrumbs_taxonomy_term' => 'my_term',
'custom_breadcrumbs_taxonomy_vocabulary' => 'my_vocabulary',
'custom_breadcrumbs_views' => 'my_view',
);
foreach ($machine_names as $type => $machine_name) {
// Ensure that the crumb is properly available.
$crumb = $this
->loadBreadcrumb($type, $machine_name);
$this
->assertTrue(!empty($crumb), t('@type present.', array(
'@type' => $type,
)));
// Ensure that the crumb is defaulted.
$states = features_get_component_states(array(
'custom_breadcrumbs_features_test',
), FALSE, TRUE);
$this
->assertTrue($states['custom_breadcrumbs_features_test'][$type] === FEATURES_DEFAULT, t('@type state: Default.', array(
'@type' => $type,
)));
// Override crumb and test that Features detects the override.
$crumb->name = 'Foo Bar';
$this
->saveBreadcrumb($type, $crumb);
$states = features_get_component_states(array(
'custom_breadcrumbs_features_test',
), FALSE, TRUE);
$this
->assertTrue($states['custom_breadcrumbs_features_test'][$type] === FEATURES_OVERRIDDEN, t('@type state: Overridden.', array(
'@type' => $type,
)));
}
// Revert crumb and ensure that crumb has reverted.
// Do this in separate loops so we only have to run
// drupal_flush_all_caches() once.
foreach ($machine_names as $type => $machine_name) {
features_revert(array(
'custom_breadcrumbs_features_test' => array(
$type,
),
));
}
drupal_flush_all_caches();
foreach ($machine_names as $type => $machine_name) {
// Reload so load funcion can clear cache if needed.
$crumb = $this
->loadBreadcrumb($type, $machine_name);
$states = features_get_component_states(array(
'custom_breadcrumbs_features_test',
), FALSE, TRUE);
$this
->assertTrue($states['custom_breadcrumbs_features_test'][$type] === FEATURES_DEFAULT, t('@type reverted.', array(
'@type' => $type,
)));
}
}