diff --git a/features.drush.inc b/features.drush.inc index 0d7a10d..74a223f 100644 --- a/features.drush.inc +++ b/features.drush.inc @@ -435,6 +435,15 @@ function drush_features_export() { if (!drush_confirm(dt('Do you really want to continue?'))) { drush_die('Aborting.'); } + _drush_features_export($items, $module, $directory); + module_enable(array($module), TRUE); + drupal_flush_all_caches(); + if (($feature = features_load_feature($module, TRUE)) && module_exists($module)) { + module_load_include('inc', 'features', 'features.export'); + _features_populate($items, $feature->info, $feature->name); + _drush_features_export($feature->info, $feature->name, dirname($feature->filename)); + } + } } else { diff --git a/tests/features.test b/tests/features.test index 8da66a3..69b944c 100644 --- a/tests/features.test +++ b/tests/features.test @@ -280,3 +280,61 @@ class FeaturesCtoolsIntegrationTest extends DrupalWebTestCase { } } } + +/** + * Tests Features' Drush integration. + */ +class FeaturesDrushExportTest extends DrupalWebTestCase { + protected $profile = 'testing'; + private $test_module = 'my_sweet_feature'; + private $test_module_path = 'public://my_sweet_feature'; + + /** + * Test info. + */ + public static function getInfo() { + return array( + 'name' => t('Drush integration'), + 'description' => t('Run tests on Features\' `drush` commands.'), + 'group' => t('Features'), + ); + } + + /** + * Set up test. + */ + public function setUp() { + parent::setUp(array('features')); + } + + public function tearDown() { + $this->deleteTestModuleFiles(); + parent::tearDown(); + } + + /** + * Test features-export command when module is not present. + */ + public function testModuleExportNew() { + // Verify the module files are not present. + $module_file_exists = is_dir($this->test_module_path); + $this->assertFalse($module_file_exists, 'The test module files are not present.'); + + // Run drush command then check that the module was created. + $stream_wrapper = file_stream_wrapper_get_instance_by_uri($this->test_module_path); + $directory = $stream_wrapper->getDirectoryPath(); + + exec("drush fe $this->test_module node:page -y --destination=\"$directory\"", $output); + + $module_file_exists = is_dir($this->test_module_path); + $this->assertTrue($module_file_exists, 'The test module has been created'); + + // Verify the component was exported. + $component_exported = is_file("$this->test_module_path/my_sweet_feature.features.field.inc"); + $this->assertTrue($component_exported, 'The component was exported succesfully.'); + + // Remove the test module. + file_unmanaged_delete_recursive($this->test_module_path); + } + +}