FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
289
sites/all/modules/contrib/admin/features/tests/features.test
Normal file
289
sites/all/modules/contrib/admin/features/tests/features.test
Normal file
@@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* User permission component tests for Features
|
||||
*/
|
||||
class FeaturesUserTestCase extends DrupalWebTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
||||
/**
|
||||
* Test info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Component tests'),
|
||||
'description' => t('Run tests for components of Features.') ,
|
||||
'group' => t('Features'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test.
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp(array(
|
||||
'field',
|
||||
'filter',
|
||||
'image',
|
||||
'taxonomy',
|
||||
'views',
|
||||
'features',
|
||||
'features_test'
|
||||
));
|
||||
|
||||
// Run a features rebuild to ensure our feature is fully installed.
|
||||
features_rebuild();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer features'));
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run test.
|
||||
*/
|
||||
public function test() {
|
||||
module_load_include('inc', 'features', 'features.export');
|
||||
|
||||
$components = array_filter(array(
|
||||
'field_instance' => '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)));
|
||||
}
|
||||
}
|
||||
|
||||
protected function _test_field_instance($op = 'load') {
|
||||
switch ($op) {
|
||||
case 'load':
|
||||
return field_info_instance('node', 'field_features_test', 'features_test');
|
||||
case 'override':
|
||||
$field_instance = field_info_instance('node', 'field_features_test', 'features_test');
|
||||
$field_instance['label'] = 'Foo bar';
|
||||
field_update_instance($field_instance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _test_filter($op = 'load') {
|
||||
// So... relying on our own API functions to test is pretty lame.
|
||||
// But these modules don't have APIs either. So might as well use
|
||||
// the ones we've written for them...
|
||||
features_include();
|
||||
switch ($op) {
|
||||
case 'load':
|
||||
return features_filter_format_load('features_test');
|
||||
case 'override':
|
||||
$format = features_filter_format_load('features_test');
|
||||
unset($format->filters['filter_url']);
|
||||
filter_format_save($format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _test_image($op = 'load') {
|
||||
switch ($op) {
|
||||
case 'load':
|
||||
return image_style_load('features_test');
|
||||
case 'override':
|
||||
$style = image_style_load('features_test');
|
||||
$style = image_style_save($style);
|
||||
foreach ($style['effects'] as $effect) {
|
||||
$effect['data']['width'] = '120';
|
||||
image_effect_save($effect);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _test_node($op = 'load') {
|
||||
switch ($op) {
|
||||
case 'load':
|
||||
return node_type_get_type('features_test');
|
||||
case 'override':
|
||||
$type = node_type_get_type('features_test');
|
||||
$type->description = 'Foo bar baz.';
|
||||
$type->modified = TRUE;
|
||||
node_type_save($type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _test_views_view($op = 'load') {
|
||||
switch ($op) {
|
||||
case 'load':
|
||||
return views_get_view('features_test', TRUE);
|
||||
case 'override':
|
||||
$view = views_get_view('features_test', TRUE);
|
||||
$view->set_display('default');
|
||||
$view->display_handler->override_option('title', 'Foo bar');
|
||||
$view->save();
|
||||
// Clear the load cache from above
|
||||
views_get_view('features_test', TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _test_user_permission($op = 'load') {
|
||||
switch ($op) {
|
||||
case 'load':
|
||||
$permissions = user_role_permissions(array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'));
|
||||
return !empty($permissions[DRUPAL_AUTHENTICATED_RID]['create features_test content']);
|
||||
case 'override':
|
||||
user_role_change_permissions(DRUPAL_AUTHENTICATED_RID, array('create features_test content' => 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests enabling of feature modules.
|
||||
*/
|
||||
class FeaturesEnableTestCase extends DrupalWebTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
||||
/**
|
||||
* Test info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Features enable tests'),
|
||||
'description' => t('Run tests for enabling of features.') ,
|
||||
'group' => t('Features'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run test for features_get_components on enable.
|
||||
*/
|
||||
public function testFeaturesGetComponents() {
|
||||
|
||||
// Testing that features_get_components returns correct after enable.
|
||||
$modules = array(
|
||||
'features',
|
||||
'taxonomy',
|
||||
'features_test',
|
||||
);
|
||||
|
||||
// Make sure features_get_components is cached if features already enabled.
|
||||
if (!module_exists('features')) {
|
||||
drupal_load('module', 'features');
|
||||
}
|
||||
features_get_components();
|
||||
|
||||
module_enable($modules);
|
||||
|
||||
// Make sure correct information for enabled modules is now cached.
|
||||
$components = features_get_components();
|
||||
$taxonomy_component_info = taxonomy_features_api();
|
||||
$this->assertTrue(!empty($components['taxonomy']) && $components['taxonomy'] == $taxonomy_component_info['taxonomy'], 'features_get_components returns correct taxonomy information on enable');
|
||||
|
||||
features_rebuild();
|
||||
$this->assertNotNull(taxonomy_vocabulary_machine_name_load('taxonomy_features_test'), 'Taxonomy vocabulary correctly enabled on enable.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests intergration of ctools for features.
|
||||
*/
|
||||
class FeaturesCtoolsIntegrationTest extends DrupalWebTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
||||
/**
|
||||
* Test info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Features Chaos Tools integration'),
|
||||
'description' => t('Run tests for ctool integration of features.') ,
|
||||
'group' => t('Features'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test.
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp(array(
|
||||
'features',
|
||||
'ctools',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Run test.
|
||||
*/
|
||||
public function testModuleEnable() {
|
||||
$try = array(
|
||||
'strongarm',
|
||||
'views',
|
||||
);
|
||||
|
||||
// Trigger the first includes and the static to be set.
|
||||
features_include();
|
||||
$function_ends = array(
|
||||
'features_export',
|
||||
'features_export_options',
|
||||
'features_export_render',
|
||||
'features_revert',
|
||||
);
|
||||
foreach ($try as $module) {
|
||||
$function = $module . '_features_api';
|
||||
$this->assertFalse(function_exists($function), 'Chaos tools functions for ' . $module . ' do not exist while it is disabled.');
|
||||
// Module enable will trigger declaring the new functions.
|
||||
module_enable(array($module));
|
||||
}
|
||||
|
||||
// CTools hooks only created when there is an actual feature exportable
|
||||
// enabled.
|
||||
module_enable(array('features_test'));
|
||||
|
||||
foreach ($try as $module) {
|
||||
if (module_exists($module)) {
|
||||
$function_exists = function_exists($function);
|
||||
if ($function_exists) {
|
||||
foreach ($function() as $component_type => $component_info) {
|
||||
foreach ($function_ends as $function_end) {
|
||||
$function_exists = $function_exists && function_exists($component_type . '_' . $function_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assertTrue($function_exists, 'Chaos tools functions for ' . $module . ' exist when it is enabled.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.features.field_base.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_bases().
|
||||
*/
|
||||
function features_test_field_default_field_bases() {
|
||||
$field_bases = array();
|
||||
|
||||
// Exported field_base: 'field_features_test'
|
||||
$field_bases['field_features_test'] = array(
|
||||
'active' => 1,
|
||||
'cardinality' => 1,
|
||||
'deleted' => 0,
|
||||
'entity_types' => array(),
|
||||
'field_name' => 'field_features_test',
|
||||
'foreign keys' => array(
|
||||
'format' => array(
|
||||
'columns' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
'table' => 'filter_format',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'format' => array(
|
||||
0 => 'format',
|
||||
),
|
||||
),
|
||||
'locked' => 0,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'max_length' => 255,
|
||||
),
|
||||
'translatable' => 1,
|
||||
'type' => 'text',
|
||||
);
|
||||
|
||||
return $field_bases;
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.features.field_instance.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_default_field_instances().
|
||||
*/
|
||||
function features_test_field_default_field_instances() {
|
||||
$field_instances = array();
|
||||
|
||||
// Exported field_instance: 'node-features_test-field_features_test'
|
||||
$field_instances['node-features_test-field_features_test'] = array(
|
||||
'bundle' => 'features_test',
|
||||
'default_value' => NULL,
|
||||
'deleted' => 0,
|
||||
'description' => '',
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'label' => 'above',
|
||||
'module' => 'text',
|
||||
'settings' => array(),
|
||||
'type' => 'text_default',
|
||||
'weight' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
'print' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
'rss' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
'teaser' => array(
|
||||
'label' => 'above',
|
||||
'settings' => array(),
|
||||
'type' => 'hidden',
|
||||
'weight' => 0,
|
||||
),
|
||||
),
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'field_features_test',
|
||||
'label' => 'Test',
|
||||
'required' => 0,
|
||||
'settings' => array(
|
||||
'text_processing' => 0,
|
||||
'user_register_form' => FALSE,
|
||||
),
|
||||
'widget' => array(
|
||||
'active' => 1,
|
||||
'module' => 'text',
|
||||
'settings' => array(
|
||||
'size' => 60,
|
||||
),
|
||||
'type' => 'text_textfield',
|
||||
'weight' => -4,
|
||||
),
|
||||
);
|
||||
|
||||
// Translatables
|
||||
// Included for use with string extractors like potx.
|
||||
t('Test');
|
||||
|
||||
return $field_instances;
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.features.filter.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_filter_default_formats().
|
||||
*/
|
||||
function features_test_filter_default_formats() {
|
||||
$formats = array();
|
||||
|
||||
// Exported format: features_test.
|
||||
$formats['features_test'] = array(
|
||||
'format' => 'features_test',
|
||||
'name' => 'features_test',
|
||||
'cache' => 1,
|
||||
'status' => 1,
|
||||
'weight' => 0,
|
||||
'filters' => array(
|
||||
'filter_autop' => array(
|
||||
'weight' => 10,
|
||||
'status' => 1,
|
||||
'settings' => array(),
|
||||
),
|
||||
'filter_html' => array(
|
||||
'weight' => 10,
|
||||
'status' => 1,
|
||||
'settings' => array(
|
||||
'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>',
|
||||
'filter_html_help' => 1,
|
||||
'filter_html_nofollow' => 0,
|
||||
),
|
||||
),
|
||||
'filter_htmlcorrector' => array(
|
||||
'weight' => 10,
|
||||
'status' => 1,
|
||||
'settings' => array(),
|
||||
),
|
||||
'filter_html_escape' => array(
|
||||
'weight' => 10,
|
||||
'status' => 1,
|
||||
'settings' => array(),
|
||||
),
|
||||
'filter_url' => array(
|
||||
'weight' => 10,
|
||||
'status' => 1,
|
||||
'settings' => array(
|
||||
'filter_url_length' => 72,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $formats;
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.features.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function features_test_ctools_plugin_api() {
|
||||
list($module, $api) = func_get_args();
|
||||
if ($module == "strongarm" && $api == "strongarm") {
|
||||
return array("version" => "1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function features_test_views_api() {
|
||||
return array("api" => "3.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_image_default_styles().
|
||||
*/
|
||||
function features_test_image_default_styles() {
|
||||
$styles = array();
|
||||
|
||||
// Exported image style: features_test.
|
||||
$styles['features_test'] = array(
|
||||
'name' => 'features_test',
|
||||
'effects' => array(
|
||||
2 => array(
|
||||
'label' => 'Scale',
|
||||
'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
|
||||
'effect callback' => 'image_scale_effect',
|
||||
'dimensions callback' => 'image_scale_dimensions',
|
||||
'form callback' => 'image_scale_form',
|
||||
'summary theme' => 'image_scale_summary',
|
||||
'module' => 'image',
|
||||
'name' => 'image_scale',
|
||||
'data' => array(
|
||||
'width' => 100,
|
||||
'height' => 100,
|
||||
'upscale' => 0,
|
||||
),
|
||||
'weight' => 1,
|
||||
),
|
||||
),
|
||||
'label' => 'features_test',
|
||||
);
|
||||
|
||||
return $styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_info().
|
||||
*/
|
||||
function features_test_node_info() {
|
||||
$items = array(
|
||||
'features_test' => array(
|
||||
'name' => t('Testing: Features'),
|
||||
'base' => 'node_content',
|
||||
'description' => t('Content type provided for Features tests.'),
|
||||
'has_title' => '1',
|
||||
'title_label' => t('Title'),
|
||||
'help' => '',
|
||||
),
|
||||
);
|
||||
return $items;
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.features.taxonomy.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_taxonomy_default_vocabularies().
|
||||
*/
|
||||
function features_test_taxonomy_default_vocabularies() {
|
||||
return array(
|
||||
'taxonomy_features_test' => array(
|
||||
'name' => 'Taxonomy Features Test',
|
||||
'machine_name' => 'taxonomy_features_test',
|
||||
'description' => 'Taxonomy vocabulary',
|
||||
'hierarchy' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'rdf_mapping' => array(
|
||||
'rdftype' => array(
|
||||
0 => 'skos:ConceptScheme',
|
||||
),
|
||||
'name' => array(
|
||||
'predicates' => array(
|
||||
0 => 'dc:title',
|
||||
),
|
||||
),
|
||||
'description' => array(
|
||||
'predicates' => array(
|
||||
0 => 'rdfs:comment',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.features.user_permission.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_user_default_permissions().
|
||||
*/
|
||||
function features_test_user_default_permissions() {
|
||||
$permissions = array();
|
||||
|
||||
// Exported permission: create features_test content.
|
||||
$permissions['create features_test content'] = array(
|
||||
'name' => 'create features_test content',
|
||||
'roles' => array(
|
||||
'anonymous user' => 'anonymous user',
|
||||
'authenticated user' => 'authenticated user',
|
||||
),
|
||||
'module' => 'node',
|
||||
);
|
||||
|
||||
return $permissions;
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
name = Features Tests
|
||||
description = Test module for Features testing.
|
||||
core = 7.x
|
||||
package = Testing
|
||||
php = 5.2.0
|
||||
dependencies[] = features
|
||||
dependencies[] = image
|
||||
dependencies[] = strongarm
|
||||
dependencies[] = taxonomy
|
||||
dependencies[] = views
|
||||
features[ctools][] = strongarm:strongarm:1
|
||||
features[ctools][] = views:views_default:3.0
|
||||
features[features_api][] = api:2
|
||||
features[field_base][] = field_features_test
|
||||
features[field_instance][] = node-features_test-field_features_test
|
||||
features[filter][] = features_test
|
||||
features[image][] = features_test
|
||||
features[node][] = features_test
|
||||
features[taxonomy][] = taxonomy_features_test
|
||||
features[user_permission][] = create features_test content
|
||||
features[views_view][] = features_test
|
||||
hidden = 1
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-10-17
|
||||
version = "7.x-2.0+0-dev"
|
||||
core = "7.x"
|
||||
project = "features"
|
||||
datestamp = "1382036080"
|
||||
|
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
include_once('features_test.features.inc');
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* features_test.views_default.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function features_test_views_default_views() {
|
||||
$export = array();
|
||||
|
||||
$view = new view();
|
||||
$view->name = 'features_test';
|
||||
$view->description = 'Test view provided by Features testing module.';
|
||||
$view->tag = 'testing';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = '';
|
||||
$view->core = 0;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Defaults */
|
||||
$handler = $view->new_display('default', 'Defaults', 'default');
|
||||
$handler->display->display_options['title'] = 'Test';
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$handler->display->display_options['access']['type'] = 'none';
|
||||
$handler->display->display_options['cache']['type'] = 'none';
|
||||
$handler->display->display_options['query']['type'] = 'views_query';
|
||||
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
||||
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
||||
$handler->display->display_options['pager']['type'] = 'full';
|
||||
$handler->display->display_options['style_plugin'] = 'default';
|
||||
$handler->display->display_options['row_plugin'] = 'node';
|
||||
$export['features_test'] = $view;
|
||||
|
||||
return $export;
|
||||
}
|
Reference in New Issue
Block a user