52 $this->moduleListMock = $this->getMockBuilder(\
Magento\Framework\
Module\ModuleListInterface::class)
53 ->setMethods([
'getNames',
'has',
'getAll',
'getOne'])
54 ->disableOriginalConstructor()
57 $this->fullModuleListMock = $this->getMockBuilder(\
Magento\Framework\
Module\FullModuleList::class)
58 ->setMethods([
'getNames',
'getAll'])
59 ->disableOriginalConstructor()
62 $this->moduleManagerMock = $this->getMockBuilder(\
Magento\Framework\
Module\Manager::class)
63 ->setMethods([
'isOutputEnabled'])
64 ->disableOriginalConstructor()
67 $this->moduleFactoryMock = $this->createPartialMock(
68 \
Magento\NewRelicReporting\Model\ModuleFactory::class,
72 $this->moduleCollectionFactoryMock = $this->createPartialMock(
78 $this->moduleListMock,
79 $this->fullModuleListMock,
80 $this->moduleManagerMock,
81 $this->moduleFactoryMock,
82 $this->moduleCollectionFactoryMock
93 $moduleCollectionMock = $this->getMockBuilder(
96 ->disableOriginalConstructor()
98 $itemMock = $this->createMock(\
Magento\NewRelicReporting\Model\Module::class);
102 'setup_version' =>
'2.0.0',
106 $testChangesMockArray = [
110 'state' =>
'enabled',
111 'setup_version' =>
'2.0.0',
112 'updated_at' =>
'2015-09-02 18:38:17'],
116 'state' =>
'disabled',
117 'setup_version' =>
'2.0.0',
118 'updated_at' =>
'2015-09-02 18:38:17'],
122 'state' =>
'uninstalled',
123 'setup_version' =>
'2.0.0',
124 'updated_at' =>
'2015-09-02 18:38:17']
126 $itemMockArray = [$itemMock];
127 $enabledModulesMockArray = [];
129 $this->moduleCollectionFactoryMock->expects($this->any())
131 ->willReturn($moduleCollectionMock);
133 $this->moduleFactoryMock->expects($this->any())
135 ->willReturn($itemMock);
137 $itemMock->expects($this->any())
141 $itemMock->expects($this->any())
145 $moduleCollectionMock->expects($this->any())
147 ->willReturn($itemMockArray);
149 $moduleCollectionMock->expects($this->any())
151 ->willReturn($testChangesMockArray);
153 $this->fullModuleListMock->expects($this->once())
155 ->willReturn($modulesMockArray);
157 $this->fullModuleListMock->expects($this->once())
159 ->willReturn($enabledModulesMockArray);
161 $this->moduleListMock->expects($this->once())
163 ->willReturn($enabledModulesMockArray);
165 $this->moduleManagerMock->expects($this->any())->method(
'isOutputEnabled')->will(
166 $this->returnValue(
false)
169 $this->assertInternalType(
171 $this->model->getModuleData()
181 public function testGetModuleDataRefresh(
$data)
183 $moduleCollectionMock = $this->getMockBuilder(
186 ->disableOriginalConstructor()
189 $itemMock = $this->createPartialMock(
190 \
Magento\NewRelicReporting\Model\Module::class,
191 [
'getName',
'getData',
'setData',
'getState',
'save']
193 $modulesMockArray = [
195 'name' =>
'Module_Name1',
196 'setup_version' =>
'2.0.0',
200 $itemMock->setData(
$data);
201 $testChangesMockArray = [
205 'state' =>
'uninstalled',
206 'setup_version' =>
'2.0.0',
207 'some_param' =>
'some_value',
208 'updated_at' =>
'2015-09-02 18:38:17' 210 $itemMockArray = [$itemMock];
212 $enabledModulesMockArray = [
'Module_Name2'];
213 $allModulesMockArray = [
'Module_Name1',
'Module_Name2'];
215 $this->moduleCollectionFactoryMock->expects($this->any())
217 ->willReturn($moduleCollectionMock);
219 $this->moduleFactoryMock->expects($this->any())
221 ->willReturn($itemMock);
223 $itemMock->expects($this->any())
227 $itemMock->expects($this->any())
231 $itemMock->expects($this->any())
233 ->willReturn(
$data[
'state']);
235 $itemMock->expects($this->any())
237 ->willReturn(
$data[
'name']);
239 $moduleCollectionMock->expects($this->any())
241 ->willReturn($itemMockArray);
243 $itemMock->expects($this->any())
245 ->willReturn($testChangesMockArray);
247 $this->fullModuleListMock->expects($this->once())
249 ->willReturn($modulesMockArray);
251 $this->fullModuleListMock->expects($this->any())
253 ->willReturn($allModulesMockArray);
255 $this->moduleListMock->expects($this->any())
257 ->willReturn($enabledModulesMockArray);
259 $this->moduleManagerMock->expects($this->any())->method(
'isOutputEnabled')->will(
260 $this->returnValue(
true)
263 $this->assertInternalType(
265 $this->model->getModuleData()
275 public function testGetModuleDataRefreshOrStatement(
$data)
277 $moduleCollectionMock = $this->getMockBuilder(
280 ->disableOriginalConstructor()
283 $itemMock = $this->createPartialMock(
284 \
Magento\NewRelicReporting\Model\Module::class,
285 [
'getName',
'getData',
'setData',
'getState',
'save']
287 $modulesMockArray = [
289 'name' =>
'Module_Name1',
290 'setup_version' =>
'2.0.0',
294 $itemMock->setData(
$data);
295 $testChangesMockArray = [
299 'state' =>
'enabled',
300 'setup_version' =>
'2.0.0',
301 'some_param' =>
'some_value',
302 'updated_at' =>
'2015-09-02 18:38:17' 304 $itemMockArray = [$itemMock];
306 $enabledModulesMockArray = [
'Module_Name2'];
307 $allModulesMockArray = [
'Module_Name1',
'Module_Name2'];
309 $this->moduleCollectionFactoryMock->expects($this->any())
311 ->willReturn($moduleCollectionMock);
313 $this->moduleFactoryMock->expects($this->any())
315 ->willReturn($itemMock);
317 $itemMock->expects($this->any())
321 $itemMock->expects($this->any())
325 $itemMock->expects($this->any())
327 ->willReturn(
$data[
'state']);
329 $itemMock->expects($this->any())
331 ->willReturn(
$data[
'name']);
333 $moduleCollectionMock->expects($this->any())
335 ->willReturn($itemMockArray);
337 $itemMock->expects($this->any())
339 ->willReturn($testChangesMockArray);
341 $this->fullModuleListMock->expects($this->once())
343 ->willReturn($modulesMockArray);
345 $this->fullModuleListMock->expects($this->any())
347 ->willReturn($allModulesMockArray);
349 $this->moduleListMock->expects($this->any())
351 ->willReturn($enabledModulesMockArray);
353 $this->moduleManagerMock->expects($this->any())->method(
'isOutputEnabled')->will(
354 $this->returnValue(
true)
357 $this->assertInternalType(
359 $this->model->getModuleData()
372 'name' =>
'Module_Name1',
374 'state' =>
'enabled',
375 'setup_version' =>
'2.0.0' 381 'name' =>
'Module_Name2',
383 'state' =>
'disabled',
384 'setup_version' =>
'2.0.0' 390 'name' =>
'Module_Name2',
392 'state' =>
'uninstalled',
393 'setup_version' =>
'2.0.0'
$moduleCollectionFactoryMock
testGetModuleDataWithoutRefresh()