11 use Symfony\Component\Console\Tester\CommandTester;
19 private $deploymentConfigMock;
25 private $objectManagerMock;
34 private $filesystemMock;
37 private $fileDriverMock;
40 private $directoryListMock;
43 private $componentRegistrarMock;
49 private $outputFormatterMock;
53 $this->deploymentConfigMock = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
54 $objectManagerProviderMock = $this->createMock(\
Magento\Setup\Model\ObjectManagerProvider::class);
55 $this->objectManagerMock = $this->getMockForAbstractClass(
56 \
Magento\Framework\ObjectManagerInterface::class,
61 $this->cacheMock = $this->getMockBuilder(\
Magento\Framework\
App\Cache::class)
62 ->disableOriginalConstructor()
65 $objectManagerProviderMock->expects($this->once())
67 ->willReturn($this->objectManagerMock);
68 $this->managerMock = $this->createMock(\
Magento\Setup\
Module\Di\
App\Task\Manager::class);
69 $this->directoryListMock =
71 $this->directoryListMock->expects($this->any())->method(
'getPath')->willReturnMap([
75 $this->filesystemMock = $this->getMockBuilder(\
Magento\Framework\Filesystem::class)
76 ->disableOriginalConstructor()
79 $this->fileDriverMock = $this->getMockBuilder(\
Magento\Framework\
Filesystem\Driver\File::class)
80 ->disableOriginalConstructor()
82 $this->componentRegistrarMock = $this->createMock(\
Magento\Framework\Component\ComponentRegistrar::class);
83 $this->componentRegistrarMock->expects($this->any())->method(
'getPaths')->willReturnMap([
88 $this->outputFormatterMock = $this->createMock(
89 \Symfony\Component\Console\Formatter\OutputFormatterInterface::class
91 $this->outputMock = $this->createMock(\Symfony\Component\Console\Output\OutputInterface::class);
92 $this->outputMock->method(
'getFormatter')
93 ->willReturn($this->outputFormatterMock);
96 $this->deploymentConfigMock,
97 $this->directoryListMock,
99 $objectManagerProviderMock,
100 $this->filesystemMock,
101 $this->fileDriverMock,
102 $this->componentRegistrarMock
108 $this->deploymentConfigMock->expects($this->once())
112 $tester =
new CommandTester($this->command);
113 $tester->execute([]);
115 'You cannot run this command because modules are not enabled. You can enable modules by running the ' 116 .
"'module:enable --all' command." . PHP_EOL,
117 $tester->getDisplay()
123 $this->directoryListMock->expects($this->atLeastOnce())->method(
'getPath')->willReturn(
null);
124 $this->objectManagerMock->expects($this->once())
127 ->willReturn($this->cacheMock);
128 $this->cacheMock->expects($this->once())->method(
'clean');
129 $writeDirectory = $this->createMock(\
Magento\Framework\
Filesystem\Directory\WriteInterface::class);
130 $writeDirectory->expects($this->atLeastOnce())->method(
'delete');
131 $this->filesystemMock->expects($this->atLeastOnce())->method(
'getDirectoryWrite')->willReturn($writeDirectory);
133 $this->deploymentConfigMock->expects($this->once())
136 ->willReturn([
'Magento_Catalog' => 1]);
137 $progressBar = new \Symfony\Component\Console\Helper\ProgressBar($this->outputMock);
139 $this->objectManagerMock->expects($this->once())->method(
'configure');
140 $this->objectManagerMock
141 ->expects($this->once())
143 ->with(\Symfony\Component\Console\Helper\ProgressBar::class)
144 ->willReturn($progressBar);
146 $this->managerMock->expects($this->exactly(7))->method(
'addOperation')
152 $this->assertEmpty(array_diff($subject[
'excludePatterns'], [
153 "#^(?:/path \(1\)/to/setup/)(/[\w]+)*/Test#",
154 "#^(?:/path/to/library/one|/path \(1\)/to/library/two)/([\w]+/)?Test#",
155 "#^(?:/path/to/library/one|/path \(1\)/to/library/two)/([\w]+/)?tests#",
156 "#^(?:/path/to/(?:module/(?:one))|/path \(1\)/to/(?:module/(?:two)))/Test#",
157 "#^(?:/path/to/(?:module/(?:one))|/path \(1\)/to/(?:module/(?:two)))/tests#" 167 $this->managerMock->expects($this->once())->method(
'process');
168 $tester =
new CommandTester($this->command);
169 $tester->execute([]);
170 $this->assertContains(
171 'Generated code and dependency injection configuration successfully.',
172 explode(PHP_EOL, $tester->getDisplay())
const DATA_ATTRIBUTES_GENERATOR
const AREA_CONFIG_GENERATOR
const REPOSITORY_GENERATOR
const APPLICATION_CODE_GENERATOR
testExecuteModulesNotEnabled()