Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions test/behaviour/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Php\PieBehaviourTest;

use Behat\Behat\Context\Context;
use Behat\Step\Then;
use Behat\Step\When;
use Composer\Util\Platform;
use Symfony\Component\Process\Process;
use Webmozart\Assert\Assert;
Expand All @@ -17,13 +19,13 @@ class CliContext implements Context
private string|null $output = null;
private int|null $exitCode = null;

/** @When I run a command to download the latest version of an extension */
#[When('I run a command to download the latest version of an extension')]
public function iRunACommandToDownloadTheLatestVersionOfAnExtension(): void
{
$this->runPieCommand(['download', 'asgrim/example-pie-extension']);
}

/** @When I run a command to download version :version of an 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]);
Expand All @@ -48,28 +50,28 @@ private function assertCommandSuccessful(): void
Assert::notNull($this->output);
}

/** @Then the latest version should have been downloaded */
#[Then('the latest version should have been downloaded')]
public function theLatestVersionShouldHaveBeenDownloaded(): void
{
$this->assertCommandSuccessful();
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: #');
}

/** @Then version :version should have been downloaded */
#[Then('version :version should have been downloaded')]
public function versionOfTheExtensionShouldHaveBeen(string $version): void
{
$this->assertCommandSuccessful();
Assert::contains($this->output, 'Found package: asgrim/example-pie-extension:' . $version);
}

/** @When I run a command to build an extension */
#[When('I run a command to build an extension')]
public function iRunACommandToBuildAnExtension(): void
{
$this->runPieCommand(['build', 'asgrim/example-pie-extension']);
}

/** @Then /^the extension should have been built$/ */
#[Then('the extension should have been built')]
public function theExtensionShouldHaveBeenBuilt(): void
{
$this->assertCommandSuccessful();
Expand All @@ -85,13 +87,13 @@ public function theExtensionShouldHaveBeenBuilt(): void
Assert::contains($this->output, 'Build complete:');
}

/** @When /^I run a command to build an extension with configure options$/ */
#[When('I run a command to build an extension with configure options')]
public function iRunACommandToBuildAnExtensionWithConfigureOptions(): void
{
$this->runPieCommand(['build', 'asgrim/example-pie-extension', '--with-hello-name=sup']);
}

/** @Then /^the extension should have been built with options$/ */
#[Then('the extension should have been built with options')]
public function theExtensionShouldHaveBeenBuiltWithOptions(): void
{
$this->assertCommandSuccessful();
Expand All @@ -107,13 +109,13 @@ public function theExtensionShouldHaveBeenBuiltWithOptions(): void
Assert::contains($this->output, 'Build complete:');
}

/** @When /^I run a command to install an extension$/ */
#[When('I run a command to install an extension')]
public function iRunACommandToInstallAnExtension(): void
{
$this->runPieCommand(['install', 'asgrim/example-pie-extension']);
}

/** @Then /^the extension should have been installed$/ */
#[Then('the extension should have been installed')]
public function theExtensionShouldHaveBeenInstalled(): void
{
$this->assertCommandSuccessful();
Expand Down