Skip to content

Commit a23b102

Browse files
authored
Merge pull request #548 from jhedstrom/518-deprecate-subcontexts
Deprecate subcontexts in Drupal Behat Extension 4.0.0.
2 parents 6445a99 + 75993f1 commit a23b102

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
* [#528](https://github.com/jhedstrom/drupalextension/pull/528) Show a more helpful failure when running `@javascript`
1111
scenarios with incorrect configuration.
1212
* [#545](https://github.com/jhedstrom/drupalextension/issue/545) Remove Zombie JS testing on Travis.
13+
* [#518](https://github.com/jhedstrom/drupalextension/issue/518) Subcontexts are deprecated and will be removed in v4.1.0.
1314
### Added
1415
* [#527](https://github.com/jhedstrom/drupalextension/pull/527) Provide a step to check that a button is not in a region.
1516
* [#543](https://github.com/jhedstrom/drupalextension/issue/543) Run gherkin-lint against feature files on Travis.

src/Drupal/DrupalExtension/Context/Environment/Reader/Reader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Drupal\DrupalDriverManager;
1414
use Drupal\Driver\SubDriverFinderInterface;
1515

16+
use Drupal\DrupalExtension\Context\DrupalSubContextInterface;
1617
use RecursiveDirectoryIterator;
1718
use RecursiveIteratorIterator;
1819
use RegexIterator;
@@ -159,6 +160,12 @@ private function findSubContextClasses()
159160

160161
// Additional subcontext locations may be specified manually in behat.yml.
161162
if (isset($this->parameters['subcontexts']['paths'])) {
163+
if (!empty($this->parameters['subcontexts']['paths'])) {
164+
@trigger_error(
165+
'The `subcontexts.paths` parameter is deprecated in Drupal Behat Extension 4.0.0 and will be removed in 4.1.0. Normal Behat contexts should be used instead and loaded via behat.yml.',
166+
E_USER_DEPRECATED
167+
);
168+
}
162169
$paths = array_merge($paths, $this->parameters['subcontexts']['paths']);
163170
}
164171

@@ -173,7 +180,8 @@ private function findSubContextClasses()
173180
$classes = get_declared_classes();
174181
foreach ($classes as $class) {
175182
$reflect = new \ReflectionClass($class);
176-
if (!$reflect->isAbstract() && $reflect->implementsInterface('Drupal\DrupalExtension\Context\DrupalSubContextInterface')) {
183+
if (!$reflect->isAbstract() && $reflect->implementsInterface(DrupalSubContextInterface::class)) {
184+
@trigger_error('Sub-contexts are deprecated in Drupal Behat Extension 4.0.0 and will be removed in 4.1.0. Class ' . $class . ' is a subcontext. This logic should be moved to a normal Behat context and loaded via behat.yml.', E_USER_DEPRECATED);
177185
$class_names[] = $class;
178186
}
179187
}

0 commit comments

Comments
 (0)