mirror of
https://github.com/opdavies/build-configs.git
synced 2025-09-06 03:15:34 +01:00
Add Behat
Add Behat as a dev dependency and add the example `ls` example. Due to a deprecation error, I needed to downgrade to PHP 8.1 on stream, though this would error the main `app:generate` command as I'm using `readonly` classes that were introduced in PHP 8.2.
This commit is contained in:
parent
65070dfb2b
commit
0d774daca0
6 changed files with 293 additions and 22 deletions
64
features/bootstrap/FeatureContext.php
Normal file
64
features/bootstrap/FeatureContext.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Gherkin\Node\PyStringNode;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
|
||||
/**
|
||||
* Defines application features from the specific context.
|
||||
*/
|
||||
class FeatureContext implements Context
|
||||
{
|
||||
/**
|
||||
* Initializes context.
|
||||
*
|
||||
* Every scenario gets its own context instance.
|
||||
* You can also pass arbitrary arguments to the
|
||||
* context constructor through behat.yml.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given I am in a directory :arg1
|
||||
*/
|
||||
public function iAmInADirectory($dir)
|
||||
{
|
||||
if (!file_exists($dir)) {
|
||||
mkdir($dir);
|
||||
}
|
||||
|
||||
chdir($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given I have a file named :arg1
|
||||
*/
|
||||
public function iHaveAFileNamed($file)
|
||||
{
|
||||
touch($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I run :arg1
|
||||
*/
|
||||
public function iRun($command)
|
||||
{
|
||||
exec($command, $output);
|
||||
|
||||
$this->output = trim(implode("\n", $output));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should get:
|
||||
*/
|
||||
public function iShouldGet(PyStringNode $string)
|
||||
{
|
||||
if ((string) $string !== $this->output) {
|
||||
throw new Exception(
|
||||
"Actual output is:\n" . $this->output
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue