Skip to content

Commit

Permalink
Renamed class, fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Feb 27, 2024
1 parent 4bca544 commit f026c1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
}

Expand All @@ -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())
);
}

Expand Down Expand Up @@ -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,
);
Expand Down
6 changes: 3 additions & 3 deletions tests/src/Kernel/CheckPackageVersionsCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}

/**
Expand Down Expand Up @@ -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(),
);
Expand Down

0 comments on commit f026c1c

Please sign in to comment.