Skip to content

Commit 892ab6f

Browse files
committed
minor symfony#59178 [AssetMapper] Adding 'Everything up to date' message (ThomasLandauer)
This PR was squashed before being merged into the 7.3 branch. Discussion ---------- [AssetMapper] Adding 'Everything up to date' message | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | not really | Deprecations? | no | Issues | | License | MIT Adding friendly message for `php bin/console importmap:outdated` if no updates are found. Wording is taken from `composer outdated` Commits ------- 2bfcd89 [AssetMapper] Adding 'Everything up to date' message
2 parents ccf91a1 + 2bfcd89 commit 892ab6f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/Symfony/Component/AssetMapper/Command/ImportMapOutdatedCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7676
$packagesUpdateInfos = $this->updateChecker->getAvailableUpdates($packages);
7777
$packagesUpdateInfos = array_filter($packagesUpdateInfos, fn ($packageUpdateInfo) => $packageUpdateInfo->hasUpdate());
7878
if (0 === \count($packagesUpdateInfos)) {
79+
if ('json' === $input->getOption('format')) {
80+
$io->writeln('[]');
81+
} else {
82+
$io->writeln('No updates found.');
83+
}
84+
7985
return Command::SUCCESS;
8086
}
8187

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\AssetMapper\Tests\ImportMap;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\AssetMapper\Command\ImportMapOutdatedCommand;
16+
use Symfony\Component\AssetMapper\ImportMap\ImportMapUpdateChecker;
17+
use Symfony\Component\Console\Tester\CommandTester;
18+
19+
class ImportMapOutdatedCommandTest extends TestCase
20+
{
21+
/**
22+
* @dataProvider provideNoOutdatedPackageCases
23+
*/
24+
public function testCommandWhenNoOutdatedPackages(string $display, ?string $format = null)
25+
{
26+
$updateChecker = $this->createMock(ImportMapUpdateChecker::class);
27+
$command = new ImportMapOutdatedCommand($updateChecker);
28+
29+
$commandTester = new CommandTester($command);
30+
$commandTester->execute(\is_string($format) ? ['--format' => $format] : []);
31+
32+
$commandTester->assertCommandIsSuccessful();
33+
$this->assertEquals($display, trim($commandTester->getDisplay(true)));
34+
}
35+
36+
/**
37+
* @return iterable<array{string, string|null}>
38+
*/
39+
public static function provideNoOutdatedPackageCases(): iterable
40+
{
41+
yield 'default' => ['No updates found.', null];
42+
yield 'txt' => ['No updates found.', 'txt'];
43+
yield 'json' => ['[]', 'json'];
44+
}
45+
}

0 commit comments

Comments
 (0)