Skip to content

Commit dae7a7d

Browse files
[self-update] Restore global new-version notifications (#300) (#301)
* Fix global version-check notifications * Update wiki submodule pointer for PR #301 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent f711a05 commit dae7a7d

4 files changed

Lines changed: 126 additions & 3 deletions

File tree

.github/wiki

Submodule wiki updated from bce2ecf to 6feadca

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Restore global DevTools new-version notifications by using a supported Symfony Process success check during release lookups (#300)
13+
1014
## [1.24.3] - 2026-04-30
1115

1216
### Fixed

src/SelfUpdate/ComposerVersionChecker.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use FastForward\DevTools\Path\DevToolsPathResolver;
2424
use FastForward\DevTools\Process\ProcessBuilderInterface;
2525
use JsonException;
26-
use Symfony\Component\Process\Process;
2726

2827
use function Safe\preg_match;
2928
use function Safe\json_decode;
@@ -83,7 +82,9 @@ private function resolveLatestStableVersion(): ?string
8382

8483
$process->setTimeout(self::TIMEOUT_SECONDS);
8584

86-
if (Process::SUCCESS !== $process->run()) {
85+
$process->run();
86+
87+
if (! $process->isSuccessful()) {
8788
return null;
8889
}
8990

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* Fast Forward Development Tools for PHP projects.
7+
*
8+
* This file is part of fast-forward/dev-tools project.
9+
*
10+
* @author Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
11+
* @license https://opensource.org/licenses/MIT MIT License
12+
*
13+
* @see https://github.com/php-fast-forward/
14+
* @see https://github.com/php-fast-forward/dev-tools
15+
* @see https://github.com/php-fast-forward/dev-tools/issues
16+
* @see https://php-fast-forward.github.io/dev-tools/
17+
* @see https://datatracker.ietf.org/doc/html/rfc2119
18+
*/
19+
20+
namespace FastForward\DevTools\Tests\SelfUpdate;
21+
22+
use FastForward\DevTools\Process\ProcessBuilderInterface;
23+
use FastForward\DevTools\SelfUpdate\ComposerVersionChecker;
24+
use PHPUnit\Framework\Attributes\CoversClass;
25+
use PHPUnit\Framework\Attributes\Test;
26+
use PHPUnit\Framework\TestCase;
27+
use Prophecy\PhpUnit\ProphecyTrait;
28+
use Prophecy\Prophecy\ObjectProphecy;
29+
use ReflectionMethod;
30+
use Symfony\Component\Process\Process;
31+
32+
#[CoversClass(ComposerVersionChecker::class)]
33+
final class ComposerVersionCheckerTest extends TestCase
34+
{
35+
use ProphecyTrait;
36+
37+
/**
38+
* @var ObjectProphecy<ProcessBuilderInterface>
39+
*/
40+
private ObjectProphecy $processBuilder;
41+
42+
private ComposerVersionChecker $checker;
43+
44+
/**
45+
* @return void
46+
*/
47+
protected function setUp(): void
48+
{
49+
$this->processBuilder = $this->prophesize(ProcessBuilderInterface::class);
50+
$this->checker = new ComposerVersionChecker($this->processBuilder->reveal());
51+
}
52+
53+
/**
54+
* @return void
55+
*/
56+
#[Test]
57+
public function resolveLatestStableVersionWillReturnFirstStableComposerVersion(): void
58+
{
59+
$process = new Process([
60+
'php',
61+
'-r',
62+
'echo json_encode(["versions" => ["1.x-dev", "v1.24.3", "v1.24.2"]]);',
63+
]);
64+
65+
$this->expectComposerShowLookup($process);
66+
67+
self::assertSame('v1.24.3', $this->invokeResolveLatestStableVersion($this->checker));
68+
}
69+
70+
/**
71+
* @return void
72+
*/
73+
#[Test]
74+
public function resolveLatestStableVersionWillReturnNullWhenComposerShowFails(): void
75+
{
76+
$process = new Process(['php', '-r', 'fwrite(STDERR, "lookup failed"); exit(1);']);
77+
78+
$this->expectComposerShowLookup($process);
79+
80+
self::assertNull($this->invokeResolveLatestStableVersion($this->checker));
81+
}
82+
83+
/**
84+
* @param Process $process
85+
*
86+
* @return void
87+
*/
88+
private function expectComposerShowLookup(Process $process): void
89+
{
90+
$builder = $this->processBuilder->reveal();
91+
92+
$this->processBuilder->withArgument('fast-forward/dev-tools')
93+
->willReturn($builder)
94+
->shouldBeCalledOnce();
95+
$this->processBuilder->withArgument('--available')
96+
->willReturn($builder)
97+
->shouldBeCalledOnce();
98+
$this->processBuilder->withArgument('--format=json')
99+
->willReturn($builder)
100+
->shouldBeCalledOnce();
101+
$this->processBuilder->withArgument('--no-interaction')
102+
->willReturn($builder)
103+
->shouldBeCalledOnce();
104+
$this->processBuilder->build('composer show')
105+
->willReturn($process)
106+
->shouldBeCalledOnce();
107+
}
108+
109+
/**
110+
* @param ComposerVersionChecker $checker
111+
*
112+
* @return ?string
113+
*/
114+
private function invokeResolveLatestStableVersion(ComposerVersionChecker $checker): ?string
115+
{
116+
return (new ReflectionMethod($checker, 'resolveLatestStableVersion'))->invoke($checker);
117+
}
118+
}

0 commit comments

Comments
 (0)