Scenario: Can get product data # tests/behat/api/solution_view.feature:12
Then test # tests/behat/api/solution_view.feature:14
Step "the response should be in JSON" is already defined in Behatch\Context\JsonContext::theResponseShouldBeInJson()
Behatch\Context\JsonContext::theResponseShouldBeInJson()
Context\ProductContext::theResponseShouldBeInJson()
class context where i want access json
<?php
declare(strict_types=1);
namespace Context;
use App\Entity\Product;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\MinkExtension\Context\MinkContext;
use Behatch\Context\JsonContext;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Behatch\Context\RestContext;
use Symfony\Component\HttpClient\HttpClient;
use Context\Auth0HelperTrait;
use Exception;
/**
* 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
*/
class ProductContext extends JsonContext implements Context
{
use Auth0HelperTrait;
/**
* @var Response|null
*/
private $response;
private $token;
public function __construct(KernelInterface $kernel)
{
$this->entityManager = $kernel->getContainer()->get('doctrine.orm.entity_manager');
$this->auth0Credentials();
$this->token = $this->handlerTokenStore();
}
/**
* @BeforeScenario
*/
public function initTokenApp(BeforeScenarioScope $scope)
{
$this->restContext = $scope->getEnvironment()->getContext(RestContext::class);
$this->restContext->iAddHeaderEqualTo('Authorization', "Bearer $this->token");
}
/**
* @Then test
*/
public function test()
{
$this->getJson();
}
}
Hi, Can you help me please? I have this error when i extends my class with JsonContext or RestContext. my conf behat.yml
Scénario ouput
class context where i want access json
Thanks