Skip to content

Commit d8a1ea9

Browse files
committed
Unit test update for quoting base path in di compile command
1 parent f11a92e commit d8a1ea9

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Component\ComponentRegistrar;
99
use Magento\Setup\Console\Command\DiCompileCommand;
10+
use Magento\Setup\Module\Di\App\Task\OperationFactory;
1011
use Symfony\Component\Console\Tester\CommandTester;
1112

1213
class DiCompileCommandTest extends \PHPUnit_Framework_TestCase
@@ -63,6 +64,9 @@ public function setUp()
6364
->willReturn($this->objectManagerMock);
6465
$this->managerMock = $this->getMock('Magento\Setup\Module\Di\App\Task\Manager', [], [], '', false);
6566
$this->directoryListMock = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
67+
$this->directoryListMock->expects($this->any())->method('getPath')->willReturnMap([
68+
[\Magento\Framework\App\Filesystem\DirectoryList::SETUP, '/path (1)/to/setup/'],
69+
]);
6670
$this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem')
6771
->disableOriginalConstructor()
6872
->getMock();
@@ -78,8 +82,8 @@ public function setUp()
7882
false
7983
);
8084
$this->componentRegistrarMock->expects($this->any())->method('getPaths')->willReturnMap([
81-
[ComponentRegistrar::MODULE, ['/path/to/module/one', '/path/to/module/two']],
82-
[ComponentRegistrar::LIBRARY, ['/path/to/library/one', '/path/to/library/two']],
85+
[ComponentRegistrar::MODULE, ['/path/to/module/one', '/path (1)/to/module/two']],
86+
[ComponentRegistrar::LIBRARY, ['/path/to/library/one', '/path (1)/to/library/two']],
8387
]);
8488

8589
$this->command = new DiCompileCommand(
@@ -136,7 +140,28 @@ public function testExecute()
136140
->method('create')
137141
->with('Symfony\Component\Console\Helper\ProgressBar')
138142
->willReturn($progressBar);
139-
$this->managerMock->expects($this->exactly(7))->method('addOperation');
143+
144+
$this->managerMock->expects($this->exactly(7))->method('addOperation')
145+
->withConsecutive(
146+
[OperationFactory::PROXY_GENERATOR, []],
147+
[OperationFactory::REPOSITORY_GENERATOR, $this->anything()],
148+
[OperationFactory::DATA_ATTRIBUTES_GENERATOR, []],
149+
[OperationFactory::APPLICATION_CODE_GENERATOR, $this->callback(function ($subject) {
150+
$this->assertEmpty(array_diff($subject['excludePatterns'], [
151+
"#^(?:/path \(1\)/to/setup/)(/[\w]+)*/Test#",
152+
"#^(?:/path/to/library/one|/path \(1\)/to/library/two)/([\w]+/)?Test#",
153+
"#^(?:/path/to/library/one|/path \(1\)/to/library/two)/([\w]+/)?tests#",
154+
"#^(?:/path/to/(?:module/(?:one))|/path \(1\)/to/(?:module/(?:two)))/Test#",
155+
"#^(?:/path/to/(?:module/(?:one))|/path \(1\)/to/(?:module/(?:two)))/tests#"
156+
]));
157+
return true;
158+
})],
159+
[OperationFactory::INTERCEPTION, $this->anything()],
160+
[OperationFactory::AREA_CONFIG_GENERATOR, $this->anything()],
161+
[OperationFactory::INTERCEPTION_CACHE, $this->anything()]
162+
)
163+
;
164+
140165
$this->managerMock->expects($this->once())->method('process');
141166
$tester = new CommandTester($this->command);
142167
$tester->execute([]);

0 commit comments

Comments
 (0)