1
0
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:
James Titcumb
2024-10-02 20:06:40 +01:00
parent 7fb9257247
commit 2df6654acd
5 changed files with 53 additions and 29 deletions

View File

@@ -7,4 +7,4 @@ default:
- Php\PieBehaviourTest\CliContext
gherkin:
filters:
tags: ~@wip
tags: "~@wip"

View File

@@ -1,15 +1,30 @@
Feature: Extensions can be installed with Behat
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
Scenario Outline: A version matching the requested constraint can be downloaded
When I run PIE command "<command>"
Then version "<version>" of package "<package>" should have been downloaded
When I run a command to download version "<constraint>" of an extension
Then version "<version>" should have been downloaded
Examples:
| command | package | version |
| download xdebug/xdebug:dev-master | xdebug/xdebug | dev-master |
| download xdebug/xdebug:3.4.0alpha1@alpha | xdebug/xdebug | 3.4.0alpha1 |
| download asgrim/example-pie-extension:^2.0 | asgrim/example-pie-extension | 2.0.0 |
| constraint | version |
| dev-main | dev-main |
| 2.0.0 | 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

View File

@@ -10,6 +10,7 @@
<file>src</file>
<file>test/unit</file>
<file>test/integration</file>
<file>test/behaviour</file>
<rule ref="Doctrine">
<exclude name="Generic.Files.LineLength.TooLong"/>

View File

@@ -13,6 +13,7 @@
<directory name="src"/>
<directory name="test/unit"/>
<directory name="test/integration"/>
<directory name="test/behaviour"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>

View File

@@ -8,46 +8,53 @@ use Behat\Behat\Context\Context;
use Symfony\Component\Process\Process;
use Webmozart\Assert\Assert;
use function array_merge;
/** @psalm-api */
class CliContext implements Context
{
private string|null $output;
private string|null $output = null;
private int|null $exitCode = null;
private string|null $errorOutput;
private int|null $exitCode;
/**
* @When I run PIE command :command
*/
public function iRunCommand(string $command) : void
/** @When I run a command to download the latest version of an extension */
public function iRunACommandToDownloadTheLatestVersionOfAnExtension(): 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();
$this->output = $proc->getOutput();
$this->errorOutput = $proc->getErrorOutput();
$this->output = $proc->getOutput();
$this->exitCode = $proc->getExitCode();
}
/**
* @Then the latest version should have been downloaded
*/
public function theLatestVersionShouldHaveBeenDownloaded() : void
/** @Then the latest version should have been downloaded */
public function theLatestVersionShouldHaveBeenDownloaded(): void
{
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, '#Extracted asgrim/example-pie-extension:v?\d+\.\d+\.\d+ source to: .+/asgrim-example-pie-extension-[a-z0-9]+#');
}
/**
* @Then version :version of package :package should have been downloaded
*/
public function versionOfTheExtensionShouldHaveBeen(string $version, string $package)
/** @Then version :version should have been downloaded */
public function versionOfTheExtensionShouldHaveBeen(string $version): void
{
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);
}
}