Example #1
0
 /**
  * Tests modules data returns array and saving in DB
  *
  * @dataProvider itemDataProvider
  * @return void
  */
 public function testGetModuleDataRefreshOrStatement($data)
 {
     $moduleCollectionMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\ResourceModel\\Module\\Collection')->disableOriginalConstructor()->getMock();
     /** @var \Magento\NewRelicReporting\Model\Module|\PHPUnit_Framework_MockObject_MockObject $itemMock */
     $itemMock = $this->getMock('Magento\\NewRelicReporting\\Model\\Module', ['getName', 'getData', 'setData', 'getState', 'save'], [], '', false);
     $modulesMockArray = ['Module_Name1' => ['name' => 'Module_Name1', 'setup_version' => '2.0.0', 'sequence' => []]];
     $itemMock->setData($data);
     $testChangesMockArray = ['entity_id' => '3', 'name' => 'Name', 'active' => 'false', 'state' => 'enabled', 'setup_version' => '2.0.0', 'some_param' => 'some_value', 'updated_at' => '2015-09-02 18:38:17'];
     $itemMockArray = [$itemMock];
     $enabledModulesMockArray = ['Module_Name2'];
     $allModulesMockArray = ['Module_Name1', 'Module_Name2'];
     $this->moduleCollectionFactoryMock->expects($this->any())->method('create')->willReturn($moduleCollectionMock);
     $this->moduleFactoryMock->expects($this->any())->method('create')->willReturn($itemMock);
     $itemMock->expects($this->any())->method('setData')->willReturnSelf();
     $itemMock->expects($this->any())->method('save')->willReturnSelf();
     $itemMock->expects($this->any())->method('getState')->willReturn($data['state']);
     $itemMock->expects($this->any())->method('getName')->willReturn($data['name']);
     $moduleCollectionMock->expects($this->any())->method('getItems')->willReturn($itemMockArray);
     $itemMock->expects($this->any())->method('getData')->willReturn($testChangesMockArray);
     $this->fullModuleListMock->expects($this->once())->method('getAll')->willReturn($modulesMockArray);
     $this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allModulesMockArray);
     $this->moduleListMock->expects($this->any())->method('getNames')->willReturn($enabledModulesMockArray);
     $this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(true));
     $this->assertInternalType('array', $this->model->getModuleData());
 }
Example #2
0
 /**
  * Get changes of module not in DB
  *
  * @param string $moduleName
  * @param string $active
  * @param string $setupVersion
  * @param string $state
  *
  * @return array
  */
 protected function getNewModuleChanges($moduleName, $active, $setupVersion, $state)
 {
     /** @var \Magento\NewRelicReporting\Model\Module $newModule */
     $newModule = $this->moduleFactory->create();
     $data = ['name' => $moduleName, 'active' => $active, 'setup_version' => $setupVersion, 'state' => $state];
     $newModule->setData($data);
     $newModule->save();
     $moduleChanges = ['name' => $data['name'], 'setup_version' => $data['setup_version'], 'type' => Config::INSTALLED];
     return $moduleChanges;
 }