mirror of
https://github.com/php/pie.git
synced 2026-03-23 23:12:17 +01:00
Improve feature description wording and outline remaining examples
This commit is contained in:
@@ -7,4 +7,4 @@ default:
|
|||||||
- Php\PieBehaviourTest\CliContext
|
- Php\PieBehaviourTest\CliContext
|
||||||
gherkin:
|
gherkin:
|
||||||
filters:
|
filters:
|
||||||
tags: ~@wip
|
tags: "~@wip"
|
||||||
|
|||||||
@@ -1,15 +1,30 @@
|
|||||||
Feature: Extensions can be installed with Behat
|
Feature: Extensions can be installed with Behat
|
||||||
|
|
||||||
Example: The latest version of an extension can be downloaded
|
Example: The latest version of an extension can be downloaded
|
||||||
When I run PIE command "download asgrim/example-pie-extension"
|
When I run a command to download the latest version of an extension
|
||||||
Then the latest version should have been downloaded
|
Then the latest version should have been downloaded
|
||||||
|
|
||||||
Scenario Outline: A version matching the requested constraint can be downloaded
|
Scenario Outline: A version matching the requested constraint can be downloaded
|
||||||
When I run PIE command "<command>"
|
When I run a command to download version "<constraint>" of an extension
|
||||||
Then version "<version>" of package "<package>" should have been downloaded
|
Then version "<version>" should have been downloaded
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
| command | package | version |
|
| constraint | version |
|
||||||
| download xdebug/xdebug:dev-master | xdebug/xdebug | dev-master |
|
| dev-main | dev-main |
|
||||||
| download xdebug/xdebug:3.4.0alpha1@alpha | xdebug/xdebug | 3.4.0alpha1 |
|
| 2.0.0 | 2.0.0 |
|
||||||
| download asgrim/example-pie-extension:^2.0 | asgrim/example-pie-extension | 2.0.0 |
|
| ^2.0 | 2.0.0 |
|
||||||
|
|
||||||
|
@wip
|
||||||
|
Example: An extension can be built
|
||||||
|
When I run a command to build an extension
|
||||||
|
Then the extension should have been built
|
||||||
|
|
||||||
|
@wip
|
||||||
|
Example: An extension can be built with configure options
|
||||||
|
When I run a command to build an extension with configure options
|
||||||
|
Then the extension should have been built
|
||||||
|
|
||||||
|
@wip
|
||||||
|
Example: An extension can be installed
|
||||||
|
When I run a command to install an extension
|
||||||
|
Then the extension should have been installed
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<file>src</file>
|
<file>src</file>
|
||||||
<file>test/unit</file>
|
<file>test/unit</file>
|
||||||
<file>test/integration</file>
|
<file>test/integration</file>
|
||||||
|
<file>test/behaviour</file>
|
||||||
|
|
||||||
<rule ref="Doctrine">
|
<rule ref="Doctrine">
|
||||||
<exclude name="Generic.Files.LineLength.TooLong"/>
|
<exclude name="Generic.Files.LineLength.TooLong"/>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<directory name="src"/>
|
<directory name="src"/>
|
||||||
<directory name="test/unit"/>
|
<directory name="test/unit"/>
|
||||||
<directory name="test/integration"/>
|
<directory name="test/integration"/>
|
||||||
|
<directory name="test/behaviour"/>
|
||||||
<ignoreFiles>
|
<ignoreFiles>
|
||||||
<directory name="vendor"/>
|
<directory name="vendor"/>
|
||||||
</ignoreFiles>
|
</ignoreFiles>
|
||||||
|
|||||||
@@ -8,46 +8,53 @@ use Behat\Behat\Context\Context;
|
|||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
use function array_merge;
|
||||||
|
|
||||||
|
/** @psalm-api */
|
||||||
class CliContext implements Context
|
class CliContext implements Context
|
||||||
{
|
{
|
||||||
private string|null $output;
|
private string|null $output = null;
|
||||||
|
private int|null $exitCode = null;
|
||||||
|
|
||||||
private string|null $errorOutput;
|
/** @When I run a command to download the latest version of an extension */
|
||||||
|
public function iRunACommandToDownloadTheLatestVersionOfAnExtension(): void
|
||||||
private int|null $exitCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @When I run PIE command :command
|
|
||||||
*/
|
|
||||||
public function iRunCommand(string $command) : void
|
|
||||||
{
|
{
|
||||||
$pieCommand = array_merge(['php', 'bin/pie'], explode(' ', $command));
|
$this->runPieCommand(['download', 'asgrim/example-pie-extension']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @When I run a command to download version :version of an extension */
|
||||||
|
public function iRunACommandToDownloadSpecificVersionOfAnExtension(string $version): void
|
||||||
|
{
|
||||||
|
$this->runPieCommand(['download', 'asgrim/example-pie-extension:' . $version]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param list<non-empty-string> $command */
|
||||||
|
public function runPieCommand(array $command): void
|
||||||
|
{
|
||||||
|
$pieCommand = array_merge(['php', 'bin/pie'], $command);
|
||||||
|
|
||||||
$proc = (new Process($pieCommand))->mustRun();
|
$proc = (new Process($pieCommand))->mustRun();
|
||||||
|
|
||||||
$this->output = $proc->getOutput();
|
$this->output = $proc->getOutput();
|
||||||
$this->errorOutput = $proc->getErrorOutput();
|
|
||||||
$this->exitCode = $proc->getExitCode();
|
$this->exitCode = $proc->getExitCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @Then the latest version should have been downloaded */
|
||||||
* @Then the latest version should have been downloaded
|
public function theLatestVersionShouldHaveBeenDownloaded(): void
|
||||||
*/
|
|
||||||
public function theLatestVersionShouldHaveBeenDownloaded() : void
|
|
||||||
{
|
{
|
||||||
Assert::same(0, $this->exitCode);
|
Assert::same(0, $this->exitCode);
|
||||||
|
|
||||||
|
Assert::notNull($this->output);
|
||||||
Assert::regex($this->output, '#Found package: asgrim/example-pie-extension:v?\d+\.\d+\.\d+ which provides ext-example_pie_extension#');
|
Assert::regex($this->output, '#Found package: asgrim/example-pie-extension:v?\d+\.\d+\.\d+ which provides ext-example_pie_extension#');
|
||||||
Assert::regex($this->output, '#Extracted asgrim/example-pie-extension:v?\d+\.\d+\.\d+ source to: .+/asgrim-example-pie-extension-[a-z0-9]+#');
|
Assert::regex($this->output, '#Extracted asgrim/example-pie-extension:v?\d+\.\d+\.\d+ source to: .+/asgrim-example-pie-extension-[a-z0-9]+#');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @Then version :version should have been downloaded */
|
||||||
* @Then version :version of package :package should have been downloaded
|
public function versionOfTheExtensionShouldHaveBeen(string $version): void
|
||||||
*/
|
|
||||||
public function versionOfTheExtensionShouldHaveBeen(string $version, string $package)
|
|
||||||
{
|
{
|
||||||
Assert::same(0, $this->exitCode);
|
Assert::same(0, $this->exitCode);
|
||||||
|
|
||||||
Assert::contains($this->output, 'Found package: ' . $package . ':' . $version);
|
Assert::notNull($this->output);
|
||||||
|
Assert::contains($this->output, 'Found package: asgrim/example-pie-extension:' . $version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user