Skip to content

Commit

Permalink
Add methods to verify the state of Drupal features.
Browse files Browse the repository at this point in the history
  • Loading branch information
becw committed Nov 24, 2015
1 parent 232ca3b commit f9023e8
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* @file
* Behat context for validating Drupal configuration.
*
* @copyright (c) Copyright 2015 Palantir.net, Inc.
*/

namespace Palantirnet\PalantirBehatExtension\Context;

class DrupalSetupContext extends SharedDrupalContext
{

/**
* @Given a Drupal site
*/
public function assertDrupal()
{
if (!$this->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)));
}
}

}

0 comments on commit f9023e8

Please sign in to comment.