mirror of
https://github.com/opdavies/build-configs.git
synced 2025-02-02 22:05:02 +00:00
65 lines
1.2 KiB
PHP
65 lines
1.2 KiB
PHP
|
<?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
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
}
|