8 use \Magento\Framework\Module\ConflictChecker;
25 $moduleListMock = $this->createMock(\
Magento\Framework\Module\ModuleList::class);
26 $packageInfoMock = $this->createMock(\
Magento\Framework\Module\PackageInfo::class);
27 $moduleListMock->expects($this->any())
29 ->will($this->returnValue($enabledModules));
30 $packageInfoMock->expects($this->any())
31 ->method(
'getConflict')
32 ->will($this->returnValueMap($conflictReturnMap));
33 $packageInfoMock->expects($this->any())
34 ->method(
'getVersion')
35 ->will($this->returnValue(
'0.1'));
36 $packageInfoFactoryMock = $this->createMock(\
Magento\Framework\Module\PackageInfoFactory::class);
37 $packageInfoFactoryMock->expects($this->once())
39 ->will($this->returnValue($packageInfoMock));
40 $conflictChecker =
new ConflictChecker($moduleListMock, $packageInfoFactoryMock);
41 $this->assertEquals($expected, $conflictChecker->checkConflictsWhenEnableModules($moduleName));
51 [[
'Vendor_A', [
'Vendor_B' =>
'0.1']], [
'Vendor_B', []]],
54 [
'Vendor_B' => [
'Vendor_A conflicts with current Vendor_B version 0.1 (version should not be 0.1)']]
57 [[
'Vendor_A', [
'Vendor_B' =>
'0.1']], [
'Vendor_B', []]],
63 [[
'Vendor_B', [
'Vendor_A' =>
'0.1']], [
'Vendor_A', []]],
66 [
'Vendor_B' => [
'Vendor_B conflicts with current Vendor_A version 0.1 (version should not be 0.1)']]
69 [[
'Vendor_B', [
'Vendor_A' =>
'0.1']], [
'Vendor_A', []]],
75 [[
'Vendor_A', []], [
'Vendor_B', []]],
81 [[
'Vendor_A', []], [
'Vendor_B', []], [
'Vendor_C', []]],
83 [
'Vendor_B',
'Vendor_C'],
84 [
'Vendor_B' => [],
'Vendor_C' => []]
87 [[
'Vendor_A', [
'Vendor_C' =>
'0.1']], [
'Vendor_B', []], [
'Vendor_C', []]],
89 [
'Vendor_B',
'Vendor_C'],
92 'Vendor_C' => [
'Vendor_A conflicts with current Vendor_C version 0.1 (version should not be 0.1)']
96 [[
'Vendor_A', []], [
'Vendor_B', [
'Vendor_C' =>
'0.1']], [
'Vendor_C', []]],
98 [
'Vendor_B',
'Vendor_C'],
100 'Vendor_B' => [
'Vendor_B conflicts with current Vendor_C version 0.1 (version should not be 0.1)'],
101 'Vendor_C' => [
'Vendor_B conflicts with current Vendor_C version 0.1 (version should not be 0.1)']
105 [[
'Vendor_A', [
'Vendor_B' =>
'>=0.1']], [
'Vendor_B', []]],
108 [
'Vendor_B' => [
'Vendor_A conflicts with current Vendor_B version 0.1 (version should not be >=0.1)']]
111 [[
'Vendor_A', [
'Vendor_B' =>
'~0.1']], [
'Vendor_B', []]],
114 [
'Vendor_B' => [
'Vendor_A conflicts with current Vendor_B version 0.1 (version should not be ~0.1)']]
121 $moduleListMock = $this->createMock(\
Magento\Framework\Module\ModuleList::class);
122 $packageInfoMock = $this->createMock(\
Magento\Framework\Module\PackageInfo::class);
123 $moduleListMock->expects($this->any())
125 ->will($this->returnValue([
'Vendor_A',
'Vendor_B']));
126 $packageInfoMock->expects($this->any())
127 ->method(
'getConflict')
128 ->will($this->returnValueMap([
131 [
'Vendor_C', [
'Vendor_A' =>
'>=0.2,<0.3',
'Vendor_B' =>
'<0.4']]
133 $packageInfoMock->expects($this->any())
134 ->method(
'getVersion')
135 ->will($this->returnValueMap([[
'Vendor_A',
'0.2'], [
'Vendor_B',
'0.4']]));
136 $packageInfoFactoryMock = $this->createMock(\
Magento\Framework\Module\PackageInfoFactory::class);
137 $packageInfoFactoryMock->expects($this->once())
139 ->will($this->returnValue($packageInfoMock));
140 $conflictChecker =
new ConflictChecker($moduleListMock, $packageInfoFactoryMock);
142 [
'Vendor_C' => [
'Vendor_C conflicts with current Vendor_A version 0.2 (version should not be >=0.2,<0.3)']],
143 $conflictChecker->checkConflictsWhenEnableModules([
'Vendor_C'])
149 $moduleListMock = $this->createMock(\
Magento\Framework\Module\ModuleList::class);
150 $packageInfoMock = $this->createMock(\
Magento\Framework\Module\PackageInfo::class);
151 $packageInfoMock->expects($this->any())
152 ->method(
'getConflict')
153 ->will($this->returnValueMap([
156 [
'Vendor_C', [
'Vendor_A' =>
'>=0.2,<0.3',
'Vendor_B' =>
'<0.4']]
158 $packageInfoMock->expects($this->any())
159 ->method(
'getVersion')
160 ->will($this->returnValueMap([[
'Vendor_A',
'0.2'], [
'Vendor_B',
'0.4']]));
161 $packageInfoFactoryMock = $this->createMock(\
Magento\Framework\Module\PackageInfoFactory::class);
162 $packageInfoFactoryMock->expects($this->once())
164 ->will($this->returnValue($packageInfoMock));
165 $conflictChecker =
new ConflictChecker($moduleListMock, $packageInfoFactoryMock);
167 [
'Vendor_C' => [
'Vendor_C conflicts with current Vendor_A version 0.2 (version should not be >=0.2,<0.3)']],
168 $conflictChecker->checkConflictsWhenEnableModules([
'Vendor_C'], [
'Vendor_A',
'Vendor_B'])
testCheckConflictWhenEnableModuleDifferentVersionWithCurEnabledModules()
testCheckConflictWhenEnableModuleDifferentVersion()
testCheckConflictsWhenEnableModules( $conflictReturnMap, $enabledModules, $moduleName, $expected)
checkConflictWhenEnableModuleDataProvider()