public function testHas() { $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertTrue($this->model->has('foo')); $this->assertFalse($this->model->has('bar')); }
public function testHas() { $this->config->expects($this->exactly(2))->method('resetData'); $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertTrue($this->model->has('foo')); $this->assertFalse($this->model->has('bar')); }
public function testHas() { $this->config->expects($this->once())->method('isAvailable')->willReturn(true); $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertTrue($this->model->has('foo')); $this->assertFalse($this->model->has('bar')); }
/** * @return ViewModel */ public function indexAction() { if ($this->moduleList->has('Magento_SampleData')) { /** @var \Magento\Framework\Setup\SampleData\State $sampleData */ $sampleData = $this->objectManagerProvider->get()->get('Magento\\Framework\\Setup\\SampleData\\State'); $isSampleDataErrorInstallation = $sampleData->hasError(); } else { $isSampleDataErrorInstallation = false; } $view = new ViewModel(['isSampleDataErrorInstallation' => $isSampleDataErrorInstallation]); $view->setTerminal(true); return $view; }
/** * Get Components info action * * @return \Zend\View\Model\JsonModel * @throws \RuntimeException * @SuppressWarnings(PHPMD.NPathComplexity) */ public function componentsAction() { $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate(); $components = $this->composerInformation->getInstalledMagentoPackages(); $allModules = $this->getAllModules(); $components = array_replace_recursive($components, $allModules); foreach ($components as $component) { $components[$component['name']]['update'] = false; $components[$component['name']]['uninstall'] = false; $components[$component['name']]['moduleName'] = $this->packageInfo->getModuleName($component['name']); if ($this->composerInformation->isPackageInComposerJson($component['name'])) { if ($component['type'] !== \Magento\Framework\Composer\ComposerInformation::METAPACKAGE_PACKAGE_TYPE) { $components[$component['name']]['uninstall'] = true; } if (isset($lastSyncData['packages'][$component['name']]['latestVersion']) && version_compare($lastSyncData['packages'][$component['name']]['latestVersion'], $component['version'], '>')) { $components[$component['name']]['update'] = true; } } if ($component['type'] === \Magento\Framework\Composer\ComposerInformation::MODULE_PACKAGE_TYPE) { $components[$component['name']]['enable'] = $this->enabledModuleList->has($components[$component['name']]['moduleName']); $components[$component['name']]['disable'] = !$components[$component['name']]['enable']; } else { $components[$component['name']]['enable'] = false; $components[$component['name']]['disable'] = false; } $componentNameParts = explode('/', $component['name']); $components[$component['name']]['vendor'] = $componentNameParts[0]; } $packagesForInstall = $this->marketplaceManager->getPackagesForInstall(); $lastSyncData = $this->formatLastSyncData($packagesForInstall, $lastSyncData); return new \Zend\View\Model\JsonModel(['success' => true, 'components' => array_values($components), 'total' => count($components), 'lastSyncData' => $lastSyncData]); }
/** * Get a list of modules that will be changed * * @param bool $isEnabled * @param string[] $modules * @return string[] */ public function getModulesToChange($isEnabled, $modules) { $changed = []; foreach ($this->getAllModules($modules) as $name) { $currentStatus = $this->list->has($name); if (in_array($name, $modules)) { if ($isEnabled != $currentStatus) { $changed[] = $name; } } } return $changed; }
/** * Parse path to identify parts needed for searching original file * * @param string $path * @throws \InvalidArgumentException * @return array */ protected function parsePath($path) { $path = ltrim($path, '/'); $parts = explode('/', $path, 6); if (count($parts) < 5) { throw new \InvalidArgumentException("Requested path '{$path}' is wrong."); } $result = []; $result['area'] = $parts[0]; $result['theme'] = $parts[1] . '/' . $parts[2]; $result['locale'] = $parts[3]; if (count($parts) >= 6 && $this->moduleList->has($parts[4])) { $result['module'] = $parts[4]; } else { $result['module'] = ''; if (isset($parts[5])) { $parts[5] = $parts[4] . '/' . $parts[5]; } else { $parts[5] = $parts[4]; } } $result['file'] = $parts[5]; return $result; }