first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
<?php
/**
* @file
* Tests for the Features Extra Block module.
*/
/**
* Tests the custom block functionality.
*/
class FeaturesExtraBlockTestCase extends DrupalWebTestCase {
// The installation profile that will be used to run the tests.
protected $profile = 'testing';
public static function getInfo() {
return array(
'name' => 'Install, revert and override',
'description' => 'Tests if a feature containing blocks and block settings can be installed, reverted and detected as being overridden.',
'group' => 'Features Extra',
);
}
public function setUp() {
parent::setUp(array(
'features_extra_test',
));
$admin_user = $this->drupalCreateUser(array('administer features'));
$this->drupalLogin($admin_user);
}
/**
* Check that all modules that are required for the test suite are available.
*/
public function testRequiredModules() {
$required_modules = array(
'block',
'ctools',
'features',
'fe_block',
'features_extra_test',
);
foreach ($required_modules as $module) {
$this->assertTrue(module_exists($module), format_string('The required module @module exists.', array('@module' => $module)));
}
}
/**
* Test if custom blocks can be reverted and that overrides are detected.
*/
public function testBlockRevert() {
module_load_include('inc', 'features', 'features.export');
// Ensure that the exported custom block is properly available.
$bid = fe_block_get_bid('features_extra_test_block');
$block = block_load('block', $bid);
$this->assertTrue(!empty($block), 'The reverted block is present.');
$components = array(
'fe_block_boxes',
'fe_block_settings',
);
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($block);
$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));
drupal_flush_all_caches();
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)));
}
}
/**
* Change the content of the test block so the component becomes overridden.
*/
protected function override_fe_block_boxes($block) {
db_update('block_custom')
->fields(array('body' => 'overridden'))
->condition('bid', $block->bid)
->execute();
}
/**
* Change a setting of the test block so the component becomes overridden.
*/
protected function override_fe_block_settings($block) {
db_update('block')
->fields(array('region' => 'footer'))
->condition('bid', $block->bid)
->condition('theme', 'bartik')
->execute();
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* @file
* features_extra_test.features.fe_block_boxes.inc
*/
/**
* Implements hook_default_fe_block_boxes().
*/
function features_extra_test_default_fe_block_boxes() {
$export = array();
$fe_block_boxes = new stdClass();
$fe_block_boxes->info = 'Features Extra Test Block';
$fe_block_boxes->format = 'filtered_html';
$fe_block_boxes->machine_name = 'features_extra_test_block';
$fe_block_boxes->body = 'This block is used in automated testing for the Features Extra module.';
$export['features_extra_test_block'] = $fe_block_boxes;
return $export;
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* @file
* features_extra_test.features.fe_block_settings.inc
*/
/**
* Implements hook_default_fe_block_settings().
*/
function features_extra_test_default_fe_block_settings() {
$export = array();
$export['version'] = '2.0';
$export['block-features_extra_test_block'] = array(
'cache' => -1,
'custom' => '0',
'machine_name' => 'features_extra_test_block',
'module' => 'block',
'node_types' => array(),
'pages' => '',
'roles' => array(),
'themes' => array(
'bartik' => array(
'region' => 'content',
'status' => '1',
'theme' => 'bartik',
'weight' => '0',
),
),
'title' => 'Features Extra',
'visibility' => '0',
);
return $export;
}

View File

@@ -0,0 +1,17 @@
name = Features Extra test feature
description = Test feature for Features Extra
core = 7.x
package = Testing
dependencies[] = fe_block
features[fe_block_boxes][] = features_extra_test_block
features[fe_block_settings][] = block-features_extra_test_block
features[features_api][] = api:1
; Information added by drupal.org packaging script on 2013-01-21
version = "7.x-1.0-alpha1+31-dev"
core = "7.x"
project = "features_extra"
datestamp = "1358772923"

View File

@@ -0,0 +1,5 @@
<?php
/**
* @file
* Drupal needs this blank file.
*/