-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Steps that checks current user has entity access of entity operations
- Loading branch information
1 parent
b15733e
commit 695f1e4
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
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,47 @@ | ||
<?php | ||
|
||
namespace Metadrop\Behat\Context; | ||
|
||
use Behat\Behat\Hook\Scope\BeforeScenarioScope; | ||
use Drupal\DrupalExtension\Context\DrupalContext; | ||
|
||
/** | ||
* Use it to have Drupal context available in your context. | ||
*/ | ||
trait DrupalContextDependencyTrait { | ||
|
||
/** | ||
* Drupal context. | ||
* | ||
* Used by contexts that depends on its methods. | ||
* | ||
* @var \Drupal\DrupalExtension\Context\DrupalContext | ||
*/ | ||
protected $drupalContext; | ||
|
||
/** | ||
* Get the Drupal context. | ||
* | ||
* It is done by searching any class that extends from DrupalContext, | ||
* it may be only one. | ||
* | ||
* It is assumed that the Drupal context is always present, as is the main | ||
* extension for behat tests in DRupal. | ||
* | ||
* @BeforeScenario | ||
* | ||
* @param BeforeScenarioScope $scope | ||
* Scope del scenario. | ||
*/ | ||
public function gatherDrupalContext(BeforeScenarioScope $scope) { | ||
$environment = $scope->getEnvironment(); | ||
$classesArray = $environment->getContextClasses(); | ||
foreach ($classesArray as $class_name) { | ||
if (is_subclass_of($class_name, DrupalContext::class) || $class_name == DrupalContext::class) { | ||
$this->drupalContext = $environment->getContext($class_name); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
} |
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