-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependency injection not working fresh install #133
Comments
the same problem |
@knnnrd had the same problem #132 All I did was to change context class constructor. Can you be more specific on what you are doing? Please paste your container configuration |
I haven't "done" anything yet except for installing the package and trying to run the example feature file. config/services_test.yaml services:
_defaults:
autowire: true
autoconfigure: true
App\Tests\Behat\:
resource: '../tests/Behat/*' tests/Behat/DemoContext.php <?php
declare(strict_types=1);
namespace App\Tests\Behat;
use Behat\Behat\Context\Context;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
/**
* This context class contains the definitions of the steps used by the demo
* feature file. Learn how to get started with Behat and BDD on Behat's website.
*
* @see http://behat.org/en/latest/quick_start.html
*/
final class DemoContext implements Context
{
/** @var KernelInterface */
private $kernel;
/** @var Response|null */
private $response;
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}
/**
* @When a demo scenario sends a request to :path
*/
public function aDemoScenarioSendsARequestTo(string $path): void
{
$this->response = $this->kernel->handle(Request::create($path, 'GET'));
}
/**
* @Then the response should be received
*/
public function theResponseShouldBeReceived(): void
{
if ($this->response === null) {
throw new \RuntimeException('No response received');
}
}
} behat.yml.dist default:
suites:
default:
contexts:
- App\Tests\Behat\DemoContext
extensions:
FriendsOfBehat\SymfonyExtension: null features/demo.feature
|
@unixslayer Any idea? |
@knnnrd sorry for delay. My current configuration looks like this ;behat.yaml.dist
default:
suites:
default:
contexts:
- behatch:context:rest
- behatch:context:json
- behatch:context:debug
- Behat\MinkExtension\Context\MinkContext
- Acme\Behat\Context\MessengerContext
extensions:
Behat\MinkExtension:
sessions:
default:
symfony: ~
Behatch\Extension: ~
FriendsOfBehat\SymfonyExtension:
bootstrap: 'features/bootstrap.php'
;config/services_test.yaml
services:
_defaults:
autowire: true
autoconfigure: true
Acme\Behat\:
resource: '../src/Acme/Behat' I haven't done anything really and everything works just fine. But what I've noticed is that Symfony cache is not rebuild after running Behat when something got change. For example, when I create new route, I have to manually remove cache |
@unixslayer Unfortunately clearing the cache also doesn't help. I tried installing all the extensions that you also have (some weird dependency maybe?), but still the same issue. I will try setting up a completely new and fresh symfony project with this library and see if the issue is also there. |
No problem at all in a fresh symfony 5.1 project. I'm kinda at a loss here on what to do. I can't show my project since it's closed-source. I haven't deviated that much I think from a standard Symfony/API Platform installation. Any more ideas? |
I don't know if it can be useful, but I had this kind of issue last time and I solved it with this conf:
services_test
(my Contexts use |
@EVDW Thanks for your input but sadly the same error |
I have this error too, just after installing the recipe. Doesn't the developer want to solve it? There are some with this bug here... I moved this configuration |
/**
* @When a demo scenario sends a request to :path
*/
public function aDemoScenarioSendsARequestTo(string $path): void
{
$this->response = $this->kernel->handle(Request::create($path, 'GET'));
} This is not how this is supposed to be used. The |
Please remember that "the developer" is actually "any developer", since this is an open source, so you're always welcome to contribute to fix things If you ask questions, the lovely people here, I'm sure, will help guide you. However, I might have the solution. I was also having this issue on a project, so I took the time to spin up a sandbox environment with a fresh symfony install, installed Behat & this extension and it worked, so then Xdebugged the 2 side by side, and found that the problem was that they DemoContext was not being found in my service container, so wasn't being autowired. The reason… I had converted my I hope this info helps all you others who might still be having this problem 🍀 |
Hi,
I'm trying to install this package but I get an error at the first step already. I should mention that I install this package through a symlink (path repository).
The steps I'm doing:
I allow the contrib recipe to be executed.
I'm a bit stuck here because installing the "official" behat symfony extension also doesn't work because I'm using Symfony 5.1.
Thanks in advance.
The text was updated successfully, but these errors were encountered: