9 use Symfony\Component\Console\Tester\CommandTester;
22 public function testExecute(array $sampleDataPackages, $appRunResult, $expectedMsg)
24 $this->
setupMocks($sampleDataPackages,
'/path/to/composer.json', $appRunResult);
25 $commandTester = $this->createCommandTester();
26 $commandTester->execute([]);
28 $this->assertEquals($expectedMsg, $commandTester->getDisplay());
43 '/path/to/composer.json',
47 $commandInput = [
'--no-update' => 1];
49 $commandTester = $this->createCommandTester();
50 $commandTester->execute($commandInput);
52 $this->assertEquals($expectedMsg, $commandTester->getDisplay());
61 'No sample data found' => [
62 'sampleDataPackages' => [],
64 'expectedMsg' =>
'There is no sample data for current set of modules.' . PHP_EOL,
66 'Successful sample data installation' => [
67 'sampleDataPackages' => [
68 'magento/module-cms-sample-data' =>
'1.0.0-beta',
79 private function createCommandTester(): CommandTester
81 $commandTester =
new CommandTester(
83 $this->filesystemMock,
84 $this->sampleDataDependencyMock,
85 $this->arrayInputFactoryMock,
86 $this->applicationFactoryMock
89 return $commandTester;
98 array $sampleDataPackages,
99 string $pathToComposerJson
102 'command' =>
'remove',
103 '--working-dir' => $pathToComposerJson,
104 '--no-interaction' => 1,
105 '--no-progress' => 1,
106 'packages' => array_keys($sampleDataPackages),
setupMocks( $sampleDataPackages, $pathToComposerJson, $appRunResult, $additionalComposerArgs=[])
testExecute(array $sampleDataPackages, $appRunResult, $expectedMsg)
expectedComposerArguments(array $sampleDataPackages, string $pathToComposerJson)
testExecuteWithNoUpdate(array $sampleDataPackages, $appRunResult, $expectedMsg)