|
| 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