PHP code example of baywa-re-lusy / behat-contexts
1. Go to this page and download the library: Download baywa-re-lusy/behat-contexts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
baywa-re-lusy / behat-contexts example snippets
use BayWaReLusy\BehatContext\HalContext\HalContextAwareTrait;
use BayWaReLusy\BehatContext\HalContext\HalContextAwareInterface;
class FeatureContext implements
...
HalContextAwareInterface
...
{
use HalContextAwareTrait;
...
/**
* @BeforeScenario
*/
public function gatherContexts(\Behat\Behat\Hook\Scope\BeforeScenarioScope $scope)
{
...
$this->gatherHalContext($scope);
$this->getHalContext()
->setJsonFilesPath(<path to directory with JSON files>)
->setBaseUrl(<API Base URL>)
->setBearerToken(<API Bearer Token>);
...
}
}
use BayWaReLusy\BehatContext\AuthContext\AuthContextAwareTrait;
use BayWaReLusy\BehatContext\AuthContext\AuthContextAwareInterface;
use BayWaReLusy\BehatContext\AuthContext\MachineToMachineCredentials;
use BayWaReLusy\BehatContext\AuthContext\UserCredentials;
class FeatureContext implements
...
AuthContextAwareInterface
...
{
use AuthContextAwareTrait;
...
/**
* @BeforeScenario
*/
public function gatherContexts(\Behat\Behat\Hook\Scope\BeforeScenarioScope $scope)
{
...
$this->gatherAuthContext($scope);
$this->getAuthContext()
->setHalContext($this->getHalContext())
->setServerAddress(<Auth Server address>)
->setTokenEndpoint(<Auth Server Token endpoint>)
->setTokenEndpoint(<Auth Server Token endpoint>)
->addMachineToMachineCredentials(new MachineToMachineCredentials(
'<Client name describing the client>',
'<Auth Client ID>',
'<Auth Client Secret>'
))
->addUserCredentials(new UserCredentials(
'<User Login>',
'<User Password>',
'<Auth Client ID>'
));
...
}
}
use BayWaReLusy\BehatContext\SqsContext\SqsContextAwareTrait;
use BayWaReLusy\BehatContext\SqsContext\SqsContextAwareInterface;
use BayWaReLusy\BehatContext\SqsContext\QueueUrl;
class FeatureContext implements
...
SqsContextAwareInterface
...
{
use SqsContextAwareTrait;
...
/**
* @BeforeScenario
*/
public function gatherContexts(\Behat\Behat\Hook\Scope\BeforeScenarioScope $scope)
{
...
$queueService = ... // <== instance of BayWaReLusy\QueueTools\QueueService
$this->gatherSqsContext($scope);
$this->getSqsContext()
->setQueueService($queueService)
->setSqsEndpoint($sqsEndpoint) // <== optional Hostname of the SQS endpoint (e.g. "http://baywa_tms_elasticmq:9324")
->setAwsRegion(<AWS Region>)
->setAwsKey(<AWS Key>)
->setAwsSecret(<AWS Secret>)
->addQueue(new QueueUrl('queueName', $queueUrl));
...
}
}
/**
* @BeforeScenario
*/
public function clearAllQueues(): void
{
// Clear all queues
$this->sqsContext->clearAllQueues();
}
use BayWaReLusy\BehatContext\ConsoleContext\ConsoleContextAwareTrait;
use BayWaReLusy\BehatContext\ConsoleContext\ConsoleContextAwareInterface;
class FeatureContext implements
...
ConsoleContextAwareInterface
...
{
use ConsoleContextAwareTrait;
...
/**
* @BeforeScenario
*/
public function gatherContexts(\Behat\Behat\Hook\Scope\BeforeScenarioScope $scope)
{
...
$this->gatherConsoleContext($scope);
...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.