Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf303b1

Browse filesBrowse files
ThomasLandauerfabpot
authored andcommitted
[AssetMapper] Adding 'Everything up to date' message
1 parent 777908c commit bf303b1
Copy full SHA for bf303b1

File tree

Expand file treeCollapse file tree

2 files changed

+51
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+51
-0
lines changed

‎Command/ImportMapOutdatedCommand.php

Copy file name to clipboardExpand all lines: Command/ImportMapOutdatedCommand.php
+6Lines 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

+45Lines 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 <fabien@symfony.com>
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.