Closed tsantos84 closed 4 years ago
You can try it by using gatherContexts() method
I am using it like this: https://github.com/OskarStark/SonataAdminBehatContext/blob/master/src/Context/SonataAdminContext.php
I've tried this snippet but I still getting the calling private method
exception.
Can you share your behat.yaml please?
@tsantos84 have you tried something like that?
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
class YourContext implements Context {
(...)
/**
* @BeforeScenario
*/
public function gatherContext(BeforeScenarioScope $beforeSuiteScope)
{
$env = $beforeSuiteScope->getEnvironment();
$this->restContext = $env->getContext(RestContext::class);
}
Hi guys. Sorry for the very long reply. I think my initial issue were with some symfony/behat/behatch version. I've just make a fresh install and now I can access Behatch context from my custom one.
I need to write a custom step on my custom context to add a header in the request. Is it possible? I've followed the official way to do so without success.
http://behat.org/en/latest/cookbooks/accessing_contexts_from_each_other.html
The error says that I can't call the private
getContext
method fromInitializedSymfonyExtensionEnvironment
class.My code:
Any idea?