From f9023e813cdfe7624f0743d2f0f4b4a852c7b3f2 Mon Sep 17 00:00:00 2001 From: Bec White Date: Tue, 24 Nov 2015 16:29:29 -0600 Subject: [PATCH] Add methods to verify the state of Drupal features. --- .../Context/DrupalSetupContext.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/Palantirnet/PalantirBehatExtension/Context/DrupalSetupContext.php diff --git a/src/Palantirnet/PalantirBehatExtension/Context/DrupalSetupContext.php b/src/Palantirnet/PalantirBehatExtension/Context/DrupalSetupContext.php new file mode 100644 index 0000000..4f8466c --- /dev/null +++ b/src/Palantirnet/PalantirBehatExtension/Context/DrupalSetupContext.php @@ -0,0 +1,56 @@ +getDriver()->isBootstrapped()) { + throw new \Exception('The Drupal site is not bootstrapped.'); + } + } + + /** + * @Then the :module module is installed + */ + public function assertModuleInstalled($module) + { + if (!module_exists('features')) { + throw new \Exception(sprintf('The "%s" module is not installed.', $module)); + } + } + + /** + * @Then no Drupal features are overridden + */ + public function assertDefaultDrupalFeatures() + { + $this->assertModuleInstalled('features'); + + module_load_include('inc', 'features', 'features.export'); + $features = features_get_features(NULL, TRUE); + + $overridden = array(); + foreach ($features as $k => $m) { + if (features_get_storage($m->name) == FEATURES_OVERRIDDEN) { + $overridden[] = $m->name; + } + } + + if (!empty($overridden)) { + throw new \Exception(sprintf('%d Drupal features are overridden: %s.', count($overridden), implode(', ', $overridden))); + } + } + +}