Skip to content

Commit a22f658

Browse files
committed
Update tests, refine ConfigCommand, and fix minor issues
1 parent 4e88ab2 commit a22f658

6 files changed

Lines changed: 34 additions & 19 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
run: composer install --prefer-dist --no-progress
5151

5252
- name: Run test suite
53-
run: composer test
53+
run: vendor/bin/phpunit --order-by random
5454

5555
- name: Run tests with coverage
5656
if: matrix.php-versions == '8.3'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</h1>
1010
<p>The PHP deployment tool with support for popular frameworks out of the box.</p>
1111

12-
<p align="center"><br><br><a href="https://deployer.org"><img src="https://medv.io/assets/deployer/deployer.gif" alt="Deployer Screenshot" width="530"></a><br><br><br></p>
12+
<p align="center"><br><br><a href="https://deployer.org"><img src="https://medv.io/assets/deployer/deployer-rounded.gif" alt="Deployer Screenshot" width="530"></a><br><br><br></p>
1313

1414
---
1515

src/Command/ConfigCommand.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,28 @@ protected function execute(Input $input, Output $output): int
4343
$data = [];
4444
$keys = $this->deployer->config->keys();
4545
WillAskUser::$noAsk = true;
46-
foreach ($hosts as $host) {
47-
Context::push(new Context($host));
48-
$values = [];
49-
foreach ($keys as $key) {
50-
try {
51-
$values[$key] = $host->get($key);
52-
} catch (WillAskUser $exception) {
53-
$values[$key] = ['ask' => $exception->getMessage()];
54-
} catch (\Throwable $exception) {
55-
$values[$key] = ['error' => $exception->getMessage()];
46+
try {
47+
foreach ($hosts as $host) {
48+
Context::push(new Context($host));
49+
$values = [];
50+
foreach ($keys as $key) {
51+
try {
52+
$values[$key] = $host->get($key);
53+
} catch (WillAskUser $exception) {
54+
$values[$key] = ['ask' => $exception->getMessage()];
55+
} catch (\Throwable $exception) {
56+
$values[$key] = ['error' => $exception->getMessage()];
57+
}
5658
}
59+
foreach ($host->config()->persist() as $k => $v) {
60+
$values[$k] = $v;
61+
}
62+
ksort($values);
63+
$data[$host->getAlias()] = $values;
64+
Context::pop();
5765
}
58-
foreach ($host->config()->persist() as $k => $v) {
59-
$values[$k] = $v;
60-
}
61-
ksort($values);
62-
$data[$host->getAlias()] = $values;
63-
Context::pop();
66+
} finally {
67+
WillAskUser::$noAsk = false;
6468
}
6569
$format = $input->getOption('format');
6670
switch ($format) {

src/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ function has(string $name): bool
763763

764764
function ask(string $message, ?string $default = null, ?array $autocomplete = null): ?string
765765
{
766-
if (WillAskUser::$noAsk) {
766+
if (WillAskUser::$noAsk) {
767767
throw new WillAskUser($message);
768768
}
769769
Context::required(__FUNCTION__);

tests/joy/JoyTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ protected static function cleanUp()
4747

4848
protected function init(string $recipe)
4949
{
50+
// Clear any leftover Context from other tests to prevent
51+
// recipe set() calls from writing to a stale host config.
52+
while (\Deployer\Task\Context::has()) {
53+
\Deployer\Task\Context::pop();
54+
}
55+
5056
$console = new Application();
5157
$console->setAutoExit(false);
5258
$this->tester = new ApplicationTester($console);

tests/legacy/DeployTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function testDeploy()
4343
}
4444
}
4545

46+
#[Depends('testDeploy')]
4647
public function testDeploySelectHosts()
4748
{
4849
$this->init(self::RECIPE);
@@ -54,6 +55,7 @@ public function testDeploySelectHosts()
5455
self::assertEquals(0, $this->tester->getStatusCode(), $this->tester->getDisplay());
5556
}
5657

58+
#[Depends('testDeploySelectHosts')]
5759
public function testKeepReleases()
5860
{
5961
for ($i = 0; $i < 3; $i++) {
@@ -92,6 +94,7 @@ public function testRollback()
9294
}
9395
}
9496

97+
#[Depends('testRollback')]
9598
public function testFail()
9699
{
97100
$this->depFile(self::RECIPE, 'deploy:fail');
@@ -120,6 +123,7 @@ public function testCleanup()
120123
}
121124
}
122125

126+
#[Depends('testCleanup')]
123127
public function testIsUnlockedExitsWithOneWhenDeployIsLocked()
124128
{
125129
$this->depFile(self::RECIPE, 'deploy:lock');
@@ -130,6 +134,7 @@ public function testIsUnlockedExitsWithOneWhenDeployIsLocked()
130134
self::assertSame(1, $this->tester->getStatusCode());
131135
}
132136

137+
#[Depends('testIsUnlockedExitsWithOneWhenDeployIsLocked')]
133138
public function testIsUnlockedExitsWithZeroWhenDeployIsNotLocked()
134139
{
135140
$this->depFile(self::RECIPE, 'deploy:unlock');

0 commit comments

Comments
 (0)