diff --git a/app/code/Magento/PageCache/Controller/Block/Render.php b/app/code/Magento/PageCache/Controller/Block/Render.php index 2758db3f57421..8afaeb27e5c3a 100644 --- a/app/code/Magento/PageCache/Controller/Block/Render.php +++ b/app/code/Magento/PageCache/Controller/Block/Render.php @@ -19,7 +19,8 @@ public function execute() $this->_forward('noroute'); return; } - + // disable profiling during private content handling AJAX call + \Magento\Framework\Profiler::reset(); $blocks = $this->_getBlocks(); $data = []; foreach ($blocks as $blockName => $blockInstance) { diff --git a/app/etc/vendor_path.php b/app/etc/vendor_path.php index bd9482bb36ae0..b6af03ef32fa4 100755 --- a/app/etc/vendor_path.php +++ b/app/etc/vendor_path.php @@ -1,10 +1,5 @@ addPsr4( - 'Magento\\', - [BP . '/dev/tests/static/framework/Magento/', realpath(__DIR__ . '/../../../Magento/')] -); +AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', [BP . '/tools/Magento/']); // parse all options if (isset($options['help'])) { @@ -42,26 +39,31 @@ $verbosity = 0 === (int)$options['verbose'] ? \Magento\Tools\View\Deployer\Log::SILENT : \Magento\Tools\View\Deployer\Log::ERROR | \Magento\Tools\View\Deployer\Log::DEBUG; } +$logger = new \Magento\Tools\View\Deployer\Log($verbosity); -// run the deployment logic -$filesUtil = new \Magento\Framework\App\Utility\Files(BP); -$omFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []); -$objectManager = $omFactory->create( - [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT] -); +try { + // run the deployment logic + $filesUtil = new \Magento\Framework\Test\Utility\Files(BP); + $omFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []); + $objectManager = $omFactory->create( + [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT] + ); -/** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ -$deploymentConfig = $objectManager->get('Magento\Framework\App\DeploymentConfig'); -$isAppInstalled = $deploymentConfig->isAvailable(); -if (!$isAppInstalled) { - throw new \Exception('Please install the Magento application before running this process.'); -} + /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ + $deploymentConfig = $objectManager->get('Magento\Framework\App\DeploymentConfig'); + $isAppInstalled = $deploymentConfig->isAvailable(); + if (!$isAppInstalled) { + throw new \Exception('You need to install the Magento application before running this utility.'); + } -$logger = new \Magento\Tools\View\Deployer\Log($verbosity); -/** @var \Magento\Tools\View\Deployer $deployer */ -$deployer = $objectManager->create( - 'Magento\Tools\View\Deployer', - ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun] -); -$deployer->deploy($omFactory, $langs); -exit(0); + /** @var \Magento\Tools\View\Deployer $deployer */ + $deployer = $objectManager->create( + 'Magento\Tools\View\Deployer', + ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun] + ); + $deployer->deploy($omFactory, $langs); +} catch (\Exception $e) { + $logger->logError($e->getMessage()); + $logger->logDebug($e->getTraceAsString()); + exit(1); +} diff --git a/lib/internal/Magento/Framework/App/StaticResource.php b/lib/internal/Magento/Framework/App/StaticResource.php index 45fe01dac839d..a4df94fc2eafd 100644 --- a/lib/internal/Magento/Framework/App/StaticResource.php +++ b/lib/internal/Magento/Framework/App/StaticResource.php @@ -99,6 +99,8 @@ public function __construct( */ public function launch() { + // disabling profiling when retrieving static resource + \Magento\Framework\Profiler::reset(); $appMode = $this->state->getMode(); if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->response->setHttpResponseCode(404); diff --git a/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php b/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php new file mode 100644 index 0000000000000..c7b92525fa6a2 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php @@ -0,0 +1,24 @@ +loader = $loader; $this->list = $list; @@ -80,6 +92,7 @@ public function __construct( $this->cleanup = $cleanup; $this->conflictChecker = $conflictChecker; $this->dependencyChecker = $dependencyChecker; + $this->deploymentConfigFactory = $deploymentConfigFactory; } /** @@ -159,7 +172,7 @@ public function setIsEnabled($isEnabled, $modules) $result[$name] = $currentStatus; } } - $segment = new ModuleList\DeploymentConfig($result); + $segment = $this->deploymentConfigFactory->create($result); $this->writer->update($segment); $this->cleanup->clearCaches(); $this->cleanup->clearCodeGeneratedFiles(); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php new file mode 100644 index 0000000000000..fc07edc800666 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php @@ -0,0 +1,26 @@ +object = new DeploymentConfigFactory(); + $this->assertInstanceOf( + 'Magento\Framework\Module\ModuleList\DeploymentConfig', + $this->object->create(['Module_One' => 0, 'Module_Two' =>1]) + ); + } +} diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php index 36ae599d5f570..f469783e91b58 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php @@ -40,6 +40,11 @@ class StatusTest extends \PHPUnit_Framework_TestCase */ private $dependencyChecker; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigFactory; + /** * @var Status */ @@ -53,13 +58,21 @@ protected function setUp() $this->cleanup = $this->getMock('Magento\Framework\App\State\Cleanup', [], [], '', false); $this->conflictChecker = $this->getMock('Magento\Framework\Module\ConflictChecker', [], [], '', false); $this->dependencyChecker = $this->getMock('Magento\Framework\Module\DependencyChecker', [], [], '', false); + $this->deploymentConfigFactory = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + [], + [], + '', + false + ); $this->object = new Status( $this->loader, $this->moduleList, $this->writer, $this->cleanup, $this->conflictChecker, - $this->dependencyChecker + $this->dependencyChecker, + $this->deploymentConfigFactory ); } @@ -167,10 +180,11 @@ public function testSetIsEnabled() $this->moduleList->expects($this->at(0))->method('has')->with('Module_Foo')->willReturn(false); $this->moduleList->expects($this->at(1))->method('has')->with('Module_Bar')->willReturn(false); $this->moduleList->expects($this->at(2))->method('has')->with('Module_Baz')->willReturn(false); - $constraint = new \PHPUnit_Framework_Constraint_IsInstanceOf( - 'Magento\Framework\Module\ModuleList\DeploymentConfig' - ); - $this->writer->expects($this->once())->method('update')->with($constraint); + $deploymentConfig = $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfig', [], [], '', false); + $expectedModules = ['Module_Foo' => 1, 'Module_Bar' => 1, 'Module_Baz' => 0]; + $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules) + ->willReturn($deploymentConfig); + $this->writer->expects($this->once())->method('update')->with($deploymentConfig); $this->cleanup->expects($this->once())->method('clearCaches'); $this->cleanup->expects($this->once())->method('clearCodeGeneratedFiles'); $this->object->setIsEnabled(true, ['Module_Foo', 'Module_Bar']); diff --git a/setup/pub/magento/setup/add-database.js b/setup/pub/magento/setup/add-database.js index b6dde9b8caf56..af4e87b7680d3 100644 --- a/setup/pub/magento/setup/add-database.js +++ b/setup/pub/magento/setup/add-database.js @@ -22,9 +22,12 @@ angular.module('add-database', ['ngStorage']) $http.post('index.php/database-check', $scope.db) .success(function (data) { $scope.testConnection.result = data; - if (!(($scope.testConnection.result !== undefined) && (!$scope.testConnection.result.success))) { + if ($scope.testConnection.result.success) { $scope.nextState(); } + }) + .error(function (data) { + $scope.testConnection.failed = data; }); }; diff --git a/setup/pub/magento/setup/readiness-check.js b/setup/pub/magento/setup/readiness-check.js index 2c46b35064292..d7c0eb243e2fc 100644 --- a/setup/pub/magento/setup/readiness-check.js +++ b/setup/pub/magento/setup/readiness-check.js @@ -32,6 +32,11 @@ angular.module('readiness-check', []) processed: false, expanded: false }; + $scope.rawpost = { + visible: false, + processed: false, + expanded: false + }; $scope.extensions = { visible: false, processed: false, @@ -57,6 +62,19 @@ angular.module('readiness-check', []) $scope.stopProgress(); } }, + 'php-rawpost': { + url:'index.php/environment/php-rawpost', + show: function() { + $scope.startProgress(); + $scope.rawpost.visible = true; + }, + process: function(data) { + $scope.rawpost.processed = true; + angular.extend($scope.rawpost, data); + $scope.updateOnProcessed($scope.rawpost.responseType); + $scope.stopProgress(); + } + }, 'php-extensions': { url:'index.php/environment/php-extensions', show: function() { diff --git a/setup/src/Magento/Setup/Controller/ConsoleController.php b/setup/src/Magento/Setup/Controller/ConsoleController.php index 1e59a5e9db825..58bf6d31f9166 100644 --- a/setup/src/Magento/Setup/Controller/ConsoleController.php +++ b/setup/src/Magento/Setup/Controller/ConsoleController.php @@ -317,6 +317,8 @@ public function __construct( $this->installer = $installerFactory->create($consoleLogger); $this->maintenanceMode = $maintenanceMode; $this->objectManagerProvider = $objectManagerProvider; + // By default we use our customized error handler, but for CLI we want to display all errors + restore_error_handler(); } /** @@ -405,6 +407,7 @@ public function installDataAction() */ public function updateAction() { + $this->installer->updateModulesSequence(); $this->installer->installSchema(); $this->installer->installDataFixtures(); } diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php index 07dc89aff7db5..8b93843046fb9 100644 --- a/setup/src/Magento/Setup/Controller/Environment.php +++ b/setup/src/Magento/Setup/Controller/Environment.php @@ -87,6 +87,29 @@ public function phpVersionAction() return new JsonModel($data); } + /** + * Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set + * + * @return JsonModel + */ + public function phpRawpostAction() + { + $iniSetting = ini_get('always_populate_raw_post_data'); + $responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS; + if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) { + $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR; + } + $data = [ + 'responseType' => $responseType, + 'data' => [ + 'version' => PHP_VERSION, + 'ini' => ini_get('always_populate_raw_post_data') + ] + ]; + + return new JsonModel($data); + } + /** * Verifies php verifications * diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index aaac7d81ac2e8..0b2772d9f45c4 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -13,12 +13,14 @@ use Magento\Framework\App\DeploymentConfig\ResourceConfig; use Magento\Framework\App\DeploymentConfig\SessionConfig; use Magento\Framework\App\DeploymentConfig\Writer; +use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\MaintenanceMode; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\FilesystemException; use Magento\Framework\Math\Random; use Magento\Framework\Module\ModuleList\DeploymentConfig; +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; use Magento\Framework\Module\ModuleList\Loader as ModuleLoader; use Magento\Framework\Module\ModuleListInterface; use Magento\Framework\Shell; @@ -102,6 +104,13 @@ class Installer */ private $deploymentConfigWriter; + /** + * Deployment configuration reader + * + * @var Writer + */ + private $deploymentConfigReader; + /** * Module list * @@ -109,6 +118,13 @@ class Installer */ private $moduleList; + /** + * Factory for module deployment config + * + * @var DeploymentConfigFactory + */ + private $deploymentConfigFactory; + /** * Module list loader * @@ -211,7 +227,9 @@ class Installer * * @param FilePermissions $filePermissions * @param Writer $deploymentConfigWriter + * @param Reader $deploymentConfigReader * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig + * @param DeploymentConfigFactory $deploymentConfigFactory * @param ModuleListInterface $moduleList * @param ModuleLoader $moduleLoader * @param DirectoryList $directoryList @@ -230,7 +248,9 @@ class Installer public function __construct( FilePermissions $filePermissions, Writer $deploymentConfigWriter, + Reader $deploymentConfigReader, \Magento\Framework\App\DeploymentConfig $deploymentConfig, + DeploymentConfigFactory $deploymentConfigFactory, ModuleListInterface $moduleList, ModuleLoader $moduleLoader, DirectoryList $directoryList, @@ -246,6 +266,8 @@ public function __construct( ) { $this->filePermissions = $filePermissions; $this->deploymentConfigWriter = $deploymentConfigWriter; + $this->deploymentConfigReader = $deploymentConfigReader; + $this->deploymentConfigFactory = $deploymentConfigFactory; $this->moduleList = $moduleList; $this->moduleLoader = $moduleLoader; $this->directoryList = $directoryList; @@ -336,7 +358,7 @@ private function createModulesConfig($request) $key = array_search($module, $toEnable); $result[$module] = false !== $key; } - return new DeploymentConfig($result); + return $this->deploymentConfigFactory->create($result); } /** @@ -786,6 +808,33 @@ public function installAdminUser($data) $adminAccount->save(); } + /** + * Updates modules in deployment configuration + * + * @return void + */ + public function updateModulesSequence() + { + $this->assertDeploymentConfigExists(); + $this->log->log('File system cleanup:'); + $this->deleteDirContents(DirectoryList::GENERATION); + $this->deleteDirContents(DirectoryList::CACHE); + $this->log->log('Updating modules:'); + $allModules = array_keys($this->moduleLoader->load()); + $deploymentConfig = $this->deploymentConfigReader->load(); + $currentModules = isset($deploymentConfig['modules']) ? $deploymentConfig['modules'] : [] ; + $result = []; + foreach ($allModules as $module) { + if (isset($currentModules[$module]) && !$currentModules[$module]) { + $result[$module] = 0; + } else { + $result[$module] = 1; + } + } + $segment = $this->deploymentConfigFactory->create($result); + $this->deploymentConfigWriter->update($segment); + } + /** * Uninstall Magento application * diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php index 826c37a97841d..6ed7fbb8d3019 100644 --- a/setup/src/Magento/Setup/Model/InstallerFactory.php +++ b/setup/src/Magento/Setup/Model/InstallerFactory.php @@ -8,6 +8,7 @@ use Zend\ServiceManager\ServiceLocatorInterface; use Magento\Setup\Module\ResourceFactory; +use Magento\Framework\App\ErrorHandler; class InstallerFactory { @@ -33,6 +34,9 @@ public function __construct(ServiceLocatorInterface $serviceLocator, ResourceFac { $this->serviceLocator = $serviceLocator; $this->resourceFactory = $resourceFactory; + // For Setup Wizard we are using our customized error handler + $handler = new ErrorHandler(); + set_error_handler([$handler, 'handler']); } /** @@ -46,7 +50,9 @@ public function create(LoggerInterface $log) return new Installer( $this->serviceLocator->get('Magento\Setup\Model\FilePermissions'), $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Writer'), + $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Reader'), $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig'), + $this->serviceLocator->get('Magento\Framework\Module\ModuleList\DeploymentConfigFactory'), $this->serviceLocator->get('Magento\Framework\Module\ModuleList'), $this->serviceLocator->get('Magento\Framework\Module\ModuleList\Loader'), $this->serviceLocator->get('Magento\Framework\App\Filesystem\DirectoryList'), diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php index 098be45fdb17f..06d50d55d388e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php @@ -165,8 +165,9 @@ public function testInstallDataAction() public function testUpdateAction() { - $this->installer->expects($this->once())->method('installSchema'); - $this->installer->expects($this->once())->method('installDataFixtures'); + $this->installer->expects($this->at(0))->method('updateModulesSequence'); + $this->installer->expects($this->at(1))->method('installSchema'); + $this->installer->expects($this->at(2))->method('installDataFixtures'); $this->controller->updateAction(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php index 19746c6b5d179..bde3f74878cf3 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php @@ -21,6 +21,10 @@ public function testCreate() 'Magento\Framework\App\DeploymentConfig\Writer', $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false), ], + [ + 'Magento\Framework\App\DeploymentConfig\Reader', + $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false), + ], [ 'Magento\Framework\App\DeploymentConfig', $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false), @@ -29,6 +33,10 @@ public function testCreate() 'Magento\Setup\Module\Setup', $this->getMock('Magento\Setup\Module\Setup', [], [], '', false), ], + [ + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfigFactory', [], [], '', false), + ], [ 'Magento\Framework\Module\ModuleList', $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false), diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index 1343dc2151c7b..b780bb25a335a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -35,6 +35,11 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $configWriter; + /** + * @var \Magento\Framework\App\DeploymentConfig\Reader|\PHPUnit_Framework_MockObject_MockObject + */ + private $configReader; + /** * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */ @@ -50,6 +55,16 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $moduleLoader; + /** + * @var \Magento\Framework\Module\ModuleList\DeploymentConfigFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigFactory; + + /** + * @var \Magento\Framework\Module\ModuleList\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfig; + /** * @var \Magento\Framework\App\Filesystem\DirectoryList|\PHPUnit_Framework_MockObject_MockObject */ @@ -121,6 +136,7 @@ protected function setUp() { $this->filePermissions = $this->getMock('Magento\Setup\Model\FilePermissions', [], [], '', false); $this->configWriter = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); + $this->configReader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); @@ -131,11 +147,20 @@ protected function setUp() ['Foo_One', 'Bar_Two'] ); $this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $allModules = [ - 'Foo_One' => [], - 'Bar_Two' => [], - ]; - $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); + $this->deploymentConfigFactory = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + [], + [], + '', + false + ); + $this->deploymentConfig = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfig', + [], + [], + '', + false + ); $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); $this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false); $this->logger = $this->getMockForAbstractClass('Magento\Setup\Model\LoggerInterface'); @@ -166,10 +191,13 @@ private function createObject($connectionFactory = false, $objectManagerProvider $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); } + return new Installer( $this->filePermissions, $this->configWriter, + $this->configReader, $this->config, + $this->deploymentConfigFactory, $this->moduleList, $this->moduleLoader, $this->directoryList, @@ -199,7 +227,12 @@ public function testInstall() [DbConfig::CONFIG_KEY, self::$dbConfig], [EncryptConfig::CONFIG_KEY, [EncryptConfig::KEY_ENCRYPTION_KEY => 'encryption_key']] ])); - + $allModules = ['Foo_One' => [], 'Bar_Two' => []]; + $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); + $modules = ['Foo_One' => 1, 'Bar_Two' => 1 ]; + $this->deploymentConfig->expects($this->any())->method('getData')->willReturn($modules); + $this->deploymentConfigFactory->expects($this->any())->method('create')->with($modules) + ->willReturn($this->deploymentConfig); $setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); $table = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false); $connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); @@ -285,6 +318,43 @@ public function testCheckApplicationFilePermissions() $this->assertSame(['message' => [$expectedMessage]], $this->object->getInstallInfo()); } + public function testUpdateModulesSequence() + { + $varDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $varDir->expects($this->exactly(2))->method('getAbsolutePath')->willReturn('/var'); + $this->filesystem + ->expects($this->exactly(2)) + ->method('getDirectoryWrite') + ->willReturn($varDir); + + $allModules = [ + 'Foo_One' => [], + 'Bar_Two' => [], + 'New_Module' => [], + ]; + $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); + + $expectedModules = [ + 'Bar_Two' => 0, + 'Foo_One' => 1, + 'New_Module' => 1 + ]; + + $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); + $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules) + ->willReturn($this->deploymentConfig); + + $newObject = $this->createObject(false, false); + $this->configReader->expects($this->once())->method('load') + ->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0] ]); + $this->configWriter->expects($this->once())->method('update')->with($this->deploymentConfig); + $this->logger->expects($this->at(0))->method('log')->with('File system cleanup:'); + $this->logger->expects($this->at(1))->method('log') + ->with('The directory \'/var\' doesn\'t exist - skipping cleanup'); + $this->logger->expects($this->at(3))->method('log')->with('Updating modules:'); + $newObject->updateModulesSequence(); + } + public function testUninstall() { $this->config->expects($this->once())->method('isAvailable')->willReturn(false); diff --git a/setup/view/magento/setup/add-database.phtml b/setup/view/magento/setup/add-database.phtml index 89606123cdf98..7f3091734e0db 100644 --- a/setup/view/magento/setup/add-database.phtml +++ b/setup/view/magento/setup/add-database.phtml @@ -42,9 +42,9 @@