Beispiel #1
0
 /**
  * @param array $expected
  *
  * @dataProvider indexActionDataProvider
  */
 public function testIndexActionWithError(array $expected)
 {
     $this->modules->expects($this->once())->method('getAllModules')->willReturn($expected['modules']);
     $this->status->expects($this->once())->method('checkConstraints')->willReturn(['ModuleA', 'ModuleB']);
     $jsonModel = $this->controller->indexAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertArrayHasKey('error', $variables);
     $this->assertFalse($variables['success']);
 }
Beispiel #2
0
 /**
  * Check Module Dependencies
  *
  * @return JsonModel
  */
 public function validateAction()
 {
     $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $status = $this->objectManager->create('Magento\\Framework\\Module\\Status');
     $constraints = $status->checkConstraints($params['status'], [$params['module']], array_diff($params['selectedModules'], [$params['module']]));
     if ($constraints) {
         $message = $this->getConstraintsFailureMessage($params['status'], $constraints);
         return new JsonModel(['success' => false, 'error' => $message]);
     }
     $this->allModules->setIsEnabled($params['status'], $params['module']);
     $allModules = $this->allModules->getAllModules($params['selectedModules']);
     ksort($allModules);
     return new JsonModel(['modules' => $allModules]);
 }
 /**
  * @param array $expectedAllModules
  * @param array $expectedConfig
  * @param array $expectedResult
  *
  * @dataProvider getAllModulesDataProvider
  */
 public function testSetIsEnabled($expectedAllModules, $expectedConfig, $expectedResult)
 {
     $this->moduleLoader->expects($this->once())->method('load')->will($this->returnValue($expectedAllModules));
     $this->deploymentConfig->expects($this->once())->method('get')->will($this->returnValue($expectedConfig));
     $this->dependencyChecker->expects($this->any())->method('checkDependenciesWhenDisableModules')->willReturn(['module1' => [], 'module2' => [], 'module3' => [], 'module4' => []]);
     $moduleStatus = new ModuleStatus($this->moduleLoader, $this->deploymentConfig, $this->objectManagerProvider);
     $moduleStatus->setIsEnabled(false, 'module1');
     $allModules = $moduleStatus->getAllModules();
     $this->assertSame(false, $allModules['module1']['selected']);
     $this->assertSame($expectedResult[1], $allModules['module2']['selected']);
     $this->assertSame($expectedResult[2], $allModules['module3']['selected']);
     $this->assertSame($expectedResult[3], $allModules['module4']['selected']);
 }