Commit 6339953e authored by Matt Glaman's avatar Matt Glaman

Issue #2532292 by mglaman: Commerce Kickstart Feature 2.x changes the display...

Issue #2532292 by mglaman: Commerce Kickstart Feature 2.x changes the display field settings to hidden
parent 6203c7bd
......@@ -31,6 +31,9 @@ env:
matrix:
fast_finish: true
include:
- php: 5.5
env: UPGRADE=7.x-2.23 TEST_FEATURES_OVERRIDES=1
install:
- "mysql -e 'create database drupal;'"
......@@ -105,8 +108,17 @@ before_script:
# Do the site install (either the current revision or old for the upgrade).
- if [[ "$UPGRADE" == none ]]; then cd drupal; else cd commerce_kickstart-$UPGRADE; fi
# Copy override module into sites/default/modules so it carries over when testing upgrades.
- if [[ "$TEST_FEATURES_OVERRIDES" == 1 ]]; then mkdir sites/default/modules && cp -r ../drupal/profiles/commerce_kickstart/tests/commerce_kickstart_overrides_test sites/default/modules/commerce_kickstart_overrides_test; fi
- drush si commerce_kickstart --db-url=mysql://root:@127.0.0.1/drupal --account-name=admin --account-pass=admin --site-mail=admin@example.com --site-name="Commerce Kickstart" --yes
- drush pm-disable dblog --yes
# If testing the override, enable it and revert feature it's overriding (because we didn't on the same install.)
- if [[ "$TEST_FEATURES_OVERRIDES" == 1 ]]; then drush en -y commerce_kickstart_overrides_test && drush fr -y commerce_kickstart_blog; fi
- cd ../drupal
# If we're an upgrade test, run the upgrade process.
......@@ -123,7 +135,8 @@ script:
- if [[ "$UPGRADE" == none ]]; then ../../scripts/check-overridden.sh; fi
# Run Behat tests.
- ./bin/behat --config behat.travis.yml
- if [[ "$TEST_FEATURES_OVERRIDES" != 1 ]]; then ./bin/behat --config behat.travis.yml --tags ~@overrides; fi
- if [[ "$TEST_FEATURES_OVERRIDES" == 1 ]]; then ./bin/behat --config behat.travis.yml --tags @overrides; fi
notifications:
......
......@@ -302,3 +302,67 @@ function commerce_kickstart_features_api_alter(&$components) {
$components['field_base']['duplicates'] = FEATURES_DUPLICATES_ALLOWED;
}
}
/**
* Implements hook_field_default_field_bases_alter().
*
* Helper alter to aid in Features Override of Features 1.x override exports
* of Fields and Field Base config.
*/
function commerce_kickstart_field_default_field_bases_alter(&$fields) {
if (module_exists('features_override')) {
$possible_alters = commerce_kickstart_get_fields_default_alters();
drupal_alter('field_default_fields_alter', $possible_alters);
foreach ($possible_alters as $identifier => $field_default) {
// Check if the alter added a field base value.
$field_name = $field_default['field_name'];
if (!isset($field_default['field_base']) || !isset($fields[$field_name])) {
continue;
}
$fields[$field_name] = drupal_array_merge_deep($fields[$field_name], $field_default['field_base']);
}
}
}
/**
* Implements hook_field_default_field_instances_alter().
*
* Helper alter to aid in Features Override of Features 1.x override exports
* of Fields and Field Instance config.
*/
function commerce_kickstart_field_default_field_instances_alter(&$fields) {
if (module_exists('features_override')) {
$possible_alters = commerce_kickstart_get_fields_default_alters();
drupal_alter('field_default_fields', $possible_alters);
foreach ($possible_alters as $identifier => $field_default) {
// Check if the alter added a field instance value.
if (!isset($field_default['field_instance']) || !isset($fields[$identifier])) {
continue;
}
$fields[$identifier] = drupal_array_merge_deep($fields[$identifier], $field_default['field_instance']);
}
}
}
/**
* Gets Features Override alters for field from 1.x
*/
function commerce_kickstart_get_fields_default_alters() {
$cache = drupal_static(__FUNCTION__, array());
if (empty($cache)) {
module_load_include('inc', 'features', 'features.export');
features_include();
// Features 1.x labeled all field data same as field instance in 2.x
features_include_defaults('field_instance');
$default_hook = features_get_default_hooks('field_instance');
// Invoke each Feature to see if they provide default field instances,
// so that we can have all possible field identifiers.
foreach (array_keys(features_get_features()) as $module) {
if (module_hook($module, $default_hook)) {
$cache = array_merge($cache, call_user_func("{$module}_{$default_hook}"));
}
}
}
return $cache;
}
@api @overrides
Feature: Customization overrides
In order to customize the distribution
As a site builder
I need my changes to remain when using Features Override
Background:
Given I am logged in as a user with the "administrator" role
Scenario: The product list view mode is disabled for Blog Post
When I am on "/admin/structure/types/manage/blog-post/display"
Then I should not see the link "Product list"
Scenario: Category and tags should be hidden from the default view
When I am on "/admin/structure/types/manage/blog-post/display"
Then the "edit-fields-field-blog-category-type" field should contain "hidden"
Then the "edit-fields-field-tags-type" field should contain "hidden"
Scenario: Category and tags should be hidden from the teaser view
When I am on "/admin/structure/types/manage/blog-post/display/teaser"
Then the "edit-fields-field-blog-category-type" field should contain "hidden"
Then the "edit-fields-field-tags-type" field should contain "hidden"
Scenario: My field label changes to blog posts should remain
When I am on "/admin/structure/types/manage/blog-post/fields"
Then I should see "Article body"
And I should see "Featured Image"
<?php
/**
* @file
* commerce_kickstart_overrides_test.features.features_overrides.inc
*/
/**
* Implements hook_features_override_default_overrides().
*/
function commerce_kickstart_overrides_test_features_override_default_overrides() {
// This code is only used for UI in features. Exported alters hooks do the magic.
$overrides = array();
// Exported overrides for: field
$overrides["field.node-blog_post-body.field_instance|label"] = 'Article body';
$overrides["field.node-blog_post-body.field_instance|required"] = 1;
$overrides["field.node-blog_post-field_blog_category.field_instance|display|default|module"]["DELETED"] = TRUE;
$overrides["field.node-blog_post-field_blog_category.field_instance|display|default|type"] = 'hidden';
$overrides["field.node-blog_post-field_blog_category.field_instance|display|teaser|module"]["DELETED"] = TRUE;
$overrides["field.node-blog_post-field_blog_category.field_instance|display|teaser|type"] = 'hidden';
$overrides["field.node-blog_post-field_image.field_instance|fences_wrapper"] = '';
$overrides["field.node-blog_post-field_image.field_instance|label"] = 'Featured Image';
$overrides["field.node-blog_post-field_tags.field_instance|display|default|module"]["DELETED"] = TRUE;
$overrides["field.node-blog_post-field_tags.field_instance|display|default|type"] = 'hidden';
$overrides["field.node-blog_post-field_tags.field_instance|display|teaser|module"]["DELETED"] = TRUE;
$overrides["field.node-blog_post-field_tags.field_instance|display|teaser|type"] = 'hidden';
$overrides["field.node-blog_post-title_field.field_instance|display|default|weight"] = '4';
$overrides["field.node-blog_post-title_field.field_instance|display|teaser|weight"] = '0';
// Exported overrides for: variable
$overrides["variable.field_bundle_settings_node__blog_post.value|view_modes|product_list|custom_settings"] = FALSE;
return $overrides;
}
<?php
/**
* @file
* commerce_kickstart_overrides_test.features.inc
*/
/**
* Implements hook_field_default_fields_alter().
*/
function commerce_kickstart_overrides_test_field_default_fields_alter(&$data) {
if (isset($data['node-blog_post-body'])) {
$data['node-blog_post-body']['field_instance']['label'] = 'Article body'; /* WAS: 'Description' */
$data['node-blog_post-body']['field_instance']['required'] = 1; /* WAS: 0 */
}
if (isset($data['node-blog_post-field_blog_category'])) {
$data['node-blog_post-field_blog_category']['field_instance']['display']['default']['type'] = 'hidden'; /* WAS: 'taxonomy_term_reference_link' */
$data['node-blog_post-field_blog_category']['field_instance']['display']['teaser']['type'] = 'hidden'; /* WAS: 'taxonomy_term_reference_link' */
unset($data['node-blog_post-field_blog_category']['field_instance']['display']['default']['module']);
unset($data['node-blog_post-field_blog_category']['field_instance']['display']['teaser']['module']);
}
if (isset($data['node-blog_post-field_image'])) {
$data['node-blog_post-field_image']['field_instance']['fences_wrapper'] = ''; /* WAS: '' */
$data['node-blog_post-field_image']['field_instance']['label'] = 'Featured Image'; /* WAS: 'Image' */
}
if (isset($data['node-blog_post-field_tags'])) {
$data['node-blog_post-field_tags']['field_instance']['display']['default']['type'] = 'hidden'; /* WAS: 'taxonomy_term_reference_link' */
$data['node-blog_post-field_tags']['field_instance']['display']['teaser']['type'] = 'hidden'; /* WAS: 'taxonomy_term_reference_link' */
unset($data['node-blog_post-field_tags']['field_instance']['display']['default']['module']);
unset($data['node-blog_post-field_tags']['field_instance']['display']['teaser']['module']);
}
if (isset($data['node-blog_post-title_field'])) {
$data['node-blog_post-title_field']['field_instance']['display']['default']['weight'] = '4'; /* WAS: 4 */
$data['node-blog_post-title_field']['field_instance']['display']['teaser']['weight'] = '0'; /* WAS: 0 */
}
}
/**
* Implements hook_strongarm_alter().
*/
function commerce_kickstart_overrides_test_strongarm_alter(&$data) {
if (isset($data['field_bundle_settings_node__blog_post'])) {
$data['field_bundle_settings_node__blog_post']->value['view_modes']['product_list']['custom_settings'] = FALSE; /* WAS: TRUE */
}
}
name = Commerce Kickstart Overrides Test
core = 7.x
package = Commerce Kickstart
dependencies[] = commerce_kickstart_blog
dependencies[] = features_override
hidden = TRUE
features[features_api][] = api:1
features[features_override_items][] = field.node-blog_post-body
features[features_override_items][] = field.node-blog_post-field_blog_category
features[features_override_items][] = field.node-blog_post-field_image
features[features_override_items][] = field.node-blog_post-field_tags
features[features_override_items][] = field.node-blog_post-title_field
features[features_override_items][] = variable.field_bundle_settings_node__blog_post
features[features_overrides][] = field.node-blog_post-body.field_instance|label
features[features_overrides][] = field.node-blog_post-body.field_instance|required
features[features_overrides][] = field.node-blog_post-field_blog_category.field_instance|display|default|module
features[features_overrides][] = field.node-blog_post-field_blog_category.field_instance|display|default|type
features[features_overrides][] = field.node-blog_post-field_blog_category.field_instance|display|teaser|module
features[features_overrides][] = field.node-blog_post-field_blog_category.field_instance|display|teaser|type
features[features_overrides][] = field.node-blog_post-field_image.field_instance|fences_wrapper
features[features_overrides][] = field.node-blog_post-field_image.field_instance|label
features[features_overrides][] = field.node-blog_post-field_tags.field_instance|display|default|module
features[features_overrides][] = field.node-blog_post-field_tags.field_instance|display|default|type
features[features_overrides][] = field.node-blog_post-field_tags.field_instance|display|teaser|module
features[features_overrides][] = field.node-blog_post-field_tags.field_instance|display|teaser|type
features[features_overrides][] = field.node-blog_post-title_field.field_instance|display|default|weight
features[features_overrides][] = field.node-blog_post-title_field.field_instance|display|teaser|weight
features[features_overrides][] = variable.field_bundle_settings_node__blog_post.value|view_modes|product_list|custom_settings
<?php
/**
* @file
* Code for the Commerce Kickstart Overrides Test feature.
*/
include_once 'commerce_kickstart_overrides_test.features.inc';
/**
* Implements hook_system_info_alter().
*
* @see features_test_system_info_alter()
*/
function commerce_kickstart_overrides_test_system_info_alter(&$info, $file, $type) {
// Don't run during installation.
if (variable_get('install_task') != 'done') {
return;
}
// Unhide the test module so tests can run properly.
if ($type == 'module' && in_array($file->name, array('commerce_kickstart_overrides_test'))) {
$info['hidden'] = FALSE;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment