1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* This file is part of the daikon-cqrs/boot project. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Daikon\Boot\Console\Command; |
10
|
|
|
|
11
|
|
|
use Daikon\Boot\Fixture\FixtureInterface; |
12
|
|
|
use Daikon\Boot\Fixture\FixtureList; |
13
|
|
|
use Daikon\Boot\Fixture\FixtureTargetInterface; |
14
|
|
|
use Daikon\Boot\Fixture\FixtureTargetMap; |
15
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Input\InputOption; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
|
20
|
|
|
final class ImportFixture extends Command |
21
|
|
|
{ |
22
|
|
|
private FixtureTargetMap $fixtureTargetMap; |
23
|
|
|
|
24
|
|
|
public function __construct(FixtureTargetMap $fixtureTargetMap) |
25
|
|
|
{ |
26
|
|
|
parent::__construct(); |
27
|
|
|
$this->fixtureTargetMap = $fixtureTargetMap; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
protected function configure(): void |
31
|
|
|
{ |
32
|
|
|
$this |
33
|
|
|
->setName('fixture:import') |
34
|
|
|
->setDescription('Import fixtures from a target.') |
35
|
|
|
->addOption( |
36
|
|
|
'target', |
37
|
|
|
null, |
38
|
|
|
InputOption::VALUE_REQUIRED, |
39
|
|
|
'Name of the target to import (if omitted all enabled targets will be imported).' |
40
|
|
|
)->addOption( |
41
|
|
|
'from', |
42
|
|
|
null, |
43
|
|
|
InputOption::VALUE_REQUIRED, |
44
|
|
|
'The version to import from (if omitted all available fixtures will be imported).' |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
49
|
|
|
{ |
50
|
|
|
$target = $input->getOption('target'); |
51
|
|
|
$from = intval($input->getOption('from')); |
52
|
|
|
|
53
|
|
|
$availableFixtures = new FixtureList; |
54
|
|
|
$loadedTargets = new FixtureTargetMap; |
55
|
|
|
$enabledTargets = $this->fixtureTargetMap->getEnabledTargets(); |
56
|
|
|
/** @var FixtureTargetInterface $fixtureTarget */ |
57
|
|
|
foreach ($enabledTargets as $targetKey => $fixtureTarget) { |
58
|
|
|
if ($target && $target !== $targetKey) { |
59
|
|
|
continue; |
60
|
|
|
} |
61
|
|
|
$fixtureList = $fixtureTarget->getFixtureList(); |
62
|
|
|
$output->writeln(sprintf( |
63
|
|
|
'Found <options=bold>%d</> fixtures for target <options=bold>%s</>', |
64
|
|
|
$fixtureList->count(), |
65
|
|
|
$targetKey |
66
|
|
|
)); |
67
|
|
|
$loadedTargets = $loadedTargets->with($targetKey, $fixtureTarget); |
68
|
|
|
$availableFixtures = $availableFixtures->append($fixtureList); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$availableFixtures = $availableFixtures->sortByVersion(); |
72
|
|
|
$importedFixtures = new FixtureList; |
73
|
|
|
|
74
|
|
|
/** @var FixtureInterface $fixture */ |
75
|
|
|
foreach ($availableFixtures as $fixture) { |
76
|
|
|
if ($fixture->getVersion() < $from) { |
77
|
|
|
continue; |
78
|
|
|
} |
79
|
|
|
/** @var FixtureTargetInterface $fixtureTarget */ |
80
|
|
|
foreach ($loadedTargets as $fixtureTarget) { |
81
|
|
|
if ($fixtureTarget->import($fixture)) { |
82
|
|
|
$importedFixtures = $importedFixtures->push($fixture); |
83
|
|
|
$output->writeln(sprintf( |
84
|
|
|
' <info>Imported fixture version %d (%s)</info>', |
85
|
|
|
$fixture->getVersion(), |
86
|
|
|
$fixture->getName() |
87
|
|
|
)); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$output->writeln(sprintf( |
93
|
|
|
'Successfully imported <options=bold>%d</> fixtures.', |
94
|
|
|
count($importedFixtures) |
95
|
|
|
)); |
96
|
|
|
|
97
|
|
|
return 0; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths