Case: In your Helper you need to use your other Helper's methods.
For example, you have common Helper for GraphQL api:
class GraphQL extends Module
{
protected $queries;
public function sendRequest($operationName, $variables = ''): void
{
$this->REST()->sendPOST(
$this->_getConfig('api_url'),
[
'operationName' => $operationName,
'query' => $this->queries[$operationName],
'variables' => \json_encode($variables),
]
);
}
/**
* @throws ModuleException
* @return Module | REST
*/
public function REST()
{
return $this->getModule('REST');
}
and then you need to use method sendRequest
to interact with your GraphQL api.
You are free to use your GraphQL Helper like you use any standard Codeception module:
class Backend extends Module
{
/**
* @return Module | GraphQL
* @throws ModuleException
*/
public function graphql()
{
return $this->getModule('GraphQL');
}
/**
* @param $username
* @param $password
* @throws ModuleException
*/
public function login($username, $password): void
{
// any actions you need
$this->graphql()->sendRequest('login', ['username' => $username, 'password' => $password]);
// set cookie if you need
}