diff --git a/tests/features.test b/tests/features.test index 8da66a3..8b25ef7 100644 --- a/tests/features.test +++ b/tests/features.test @@ -280,3 +280,69 @@ class FeaturesCtoolsIntegrationTest extends DrupalWebTestCase { } } } + + + +/** + * Tests Features Drush Functionality. + */ +class FeaturesDrushExportTest extends DrupalWebTestCase { + protected $profile = 'testing'; + private $test_module = 'my_sweet_feature'; + private $test_module_path = "sites/all/modules/my_sweet_feature"; + + /** + * Test info. + */ + public static function getInfo() { + return array( + 'name' => t('Features drush functionality.'), + 'description' => t('Run functional 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() { + // We need to make sure the module does not exist. + $this->deleteTestModuleFiles(); + + // 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 then check that the module was created. + exec("drush -y fe $this->test_module node:page", $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."); + + } + + + /** + * If a test module is found, remove it from the system. + */ + private function deleteTestModuleFiles() { + file_unmanaged_delete_recursive($this->test_module_path); + } + +}