Skip to content

Commit

Permalink
Add dry option to load all command
Browse files Browse the repository at this point in the history
  • Loading branch information
jkniest committed Apr 3, 2024
1 parent 7f7e0ff commit c8f51ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 19 additions & 1 deletion src/Command/LoadFixturesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Basecom\FixturePlugin\Command;

use Basecom\FixturePlugin\FixtureLoader;
use Basecom\FixturePlugin\FixtureOption;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -20,13 +21,30 @@ public function __construct(
parent::__construct();
}

protected function configure(): void
{
$this->addOption('dry', description: 'Only list fixtures that would run without executing them');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

$dry = (bool) ($input->getOption('dry') ?? false);

$io->title('Running all fixtures');

$this->loader->runAll($io);
if ($dry) {
$io->note('[INFO] Dry run mode enabled. No fixtures will be executed.');
}

$option = new FixtureOption(
dryMode: $dry
);

if (!$this->loader->run($option, $io)) {
return Command::FAILURE;
}

$io->success('Done!');

Expand Down
6 changes: 0 additions & 6 deletions src/FixtureLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ private function prefilterFixtures(FixtureOption $option): array
return $fixtures;
}

public function runAll(SymfonyStyle $io): void
{
$this->fixtureReference = $this->buildFixtureReference($this->fixtures);
$this->runFixtures(new FixtureOption(), $this->fixtures, $io);
}

public function runSingle(SymfonyStyle $io, string $fixtureName, bool $withDependencies = false): void
{
foreach ($this->fixtures as $fixture) {
Expand Down

0 comments on commit c8f51ca

Please sign in to comment.