Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Symfony4/Behat inject function not working "you have requested a non-existen service"

$
0
0

For a testcase i need to be able to use an existing service, but this service cannot be used in my behat context:

Context:

/**class CustomContext extends MinkContext implements KernelAwareContext {    # ...     * @param EntityManagerInterface $em     * @param HttpCallResultPool $httpCallResultPool     * @param SessionInterface $session     * @param CustomService $customService     * @param string $evaluationMode     */    public function __construct(        EntityManagerInterface $em,        HttpCallResultPool $httpCallResultPool,        SessionInterface $session,        CustomService $customService,        string $evaluationMode = 'javascript'    ) {        $this->em = $em;        $this->client = new Client();        $this->inspector = new JsonInspector($evaluationMode);        $this->httpCallResultPool = $httpCallResultPool;        $this->session = $session;        $this->customService= $customService;    }

behat.yaml:

# ...    Behat\Symfony2Extension:      kernel:        bootstrap: 'config/bootstrap.php'        path: 'src/Kernel.php'        class: 'App\Kernel'        env: dev         debug: false # ...suites:    default:      contexts:        - App\CustomContext:            em: '@doctrine.orm.default_entity_manager'            session: '@session'            customService: '@App\Service\CustomService'

Fehlermeldung:

In Container.php line 289:  You have requested a non-existent service "App\Service\CustomService".

Can someone help or has an idea why this error message is shown?The Service does work in the used controller. So there should be no error with the service itself, only with injecting this service into behat.


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>