-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods to verify the state of Drupal features.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/Palantirnet/PalantirBehatExtension/Context/DrupalSetupContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 I have a Drupal site | ||
*/ | ||
public function iHaveADrupalSite() | ||
{ | ||
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))); | ||
} | ||
} | ||
|
||
} |