diff --git a/src/Drush/Commands/CheckPackageVersionsCommands.php b/src/Drush/Commands/PackageScannerDrushCommands.php similarity index 91% rename from src/Drush/Commands/CheckPackageVersionsCommands.php rename to src/Drush/Commands/PackageScannerDrushCommands.php index 1c4ff79..0eace6c 100644 --- a/src/Drush/Commands/CheckPackageVersionsCommands.php +++ b/src/Drush/Commands/PackageScannerDrushCommands.php @@ -10,13 +10,14 @@ use Drush\Attributes\Argument; use Drush\Attributes\Command; use Drush\Commands\DrushCommands; +use Drush\Drush; use Symfony\Component\Console\Style\StyleInterface; use Symfony\Component\Console\Style\SymfonyStyle; /** * A drush command to check whether given Helfi packages are up-to-date. */ -final class CheckPackageVersionsCommands extends DrushCommands { +final class PackageScannerDrushCommands extends DrushCommands { /** * Constructs a new instance. @@ -28,9 +29,8 @@ final class CheckPackageVersionsCommands extends DrushCommands { */ public function __construct( private readonly VersionChecker $versionChecker, - ?StyleInterface $io = NULL, + private readonly StyleInterface $style, ) { - $this->io = $io ?: new SymfonyStyle($this->input(), $this->output()); parent::__construct(); } @@ -40,6 +40,7 @@ public function __construct( public static function create(ContainerInterface $container): self { return new self( $container->get('helfi_api_base.package_version_checker'), + new SymfonyStyle(Drush::input(),Drush::output()) ); } @@ -77,7 +78,7 @@ public function checkVersions(string $file) : int { return DrushCommands::EXIT_SUCCESS; } - $this->io->table( + $this->style->table( ['Name', 'Version', 'Latest version'], $versions, ); diff --git a/tests/src/Kernel/CheckPackageVersionsCommandsTest.php b/tests/src/Kernel/CheckPackageVersionsCommandsTest.php index d0e0b32..4889c44 100644 --- a/tests/src/Kernel/CheckPackageVersionsCommandsTest.php +++ b/tests/src/Kernel/CheckPackageVersionsCommandsTest.php @@ -6,7 +6,7 @@ use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\helfi_api_base\Traits\ApiTestTrait; -use DrupalTools\Drush\Commands\CheckPackageVersionsCommands; +use DrupalTools\Drush\Commands\PackageScannerDrushCommands; use Drush\Commands\DrushCommands; use GuzzleHttp\Psr7\Response; use Prophecy\Argument; @@ -33,7 +33,7 @@ final class CheckPackageVersionsCommandsTest extends KernelTestBase { */ public function testInvalidComposerFile() : void { $this->expectException(\RuntimeException::class); - CheckPackageVersionsCommands::create($this->container)->checkVersions('nonexistent.lock'); + PackageScannerDrushCommands::create($this->container)->checkVersions('nonexistent.lock'); } /** @@ -71,7 +71,7 @@ public function testVersionCheck() : void { ], ])->shouldBeCalledTimes(1); - $sut = new CheckPackageVersionsCommands( + $sut = new PackageScannerDrushCommands( $this->container->get('helfi_api_base.package_version_checker'), $io->reveal(), );