From 05995a900fd83a8a35d8d8b2dadbcc49830a9829 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Thu, 31 Mar 2016 15:50:41 -0500
Subject: [PATCH 01/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- prototype of regenerate flag
---
lib/internal/Magento/Framework/App/Bootstrap.php | 14 ++++++++++++++
.../Command/AbstractModuleManageCommand.php | 3 +++
2 files changed, 17 insertions(+)
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index 6658b099c1204..ae109f237aefa 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -117,6 +117,20 @@ class Bootstrap
*/
public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null)
{
+ if (file_exists(BP . '/var/.regenerate')) {
+ $generationPath = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION])
+ ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION]
+ : BP . '/var/generation';
+ $diPath = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI])
+ ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI] : BP . '/var/di';
+ if (is_dir($generationPath)) {
+ \Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
+ }
+ if (is_dir($diPath)) {
+ \Magento\Framework\Filesystem\Io\File::rmdirRecursive($diPath);
+ }
+ unlink(BP . '/var/.regenerate');
+ }
self::populateAutoloader($rootDir, $initParams);
if ($factory === null) {
$factory = self::createObjectManagerFactory($rootDir, $initParams);
diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
index 143632420a226..97836010db02c 100644
--- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
@@ -101,6 +101,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('');
}
$this->cleanup($input, $output);
+
+ touch(BP . '/var/.regenerate');
+
if ($force) {
$output->writeln(
'Alert: You used the --force option.'
From 2c52284d62437888403bb119bc219df110e97709 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Fri, 1 Apr 2016 15:07:20 -0500
Subject: [PATCH 02/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- prototype of adding disable cache work flow
---
.../Magento/Setup/Controller/StartUpdater.php | 8 +++
.../Magento/Setup/Model/Cron/JobFactory.php | 24 +++++++
.../Magento/Setup/Model/Cron/JobSetCache.php | 72 +++++++++++++++++++
3 files changed, 104 insertions(+)
create mode 100644 setup/src/Magento/Setup/Model/Cron/JobSetCache.php
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index 98da8143cf5fb..031c8914bf6b3 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -108,6 +108,14 @@ public function updateAction()
['enable' => true]
);
+ if ($jobType == 'update' || $jobType == 'upgrade') {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
+ []
+ );
+ }
+
$errorMessage .= $this->updater->createUpdaterTask(
$packages,
$cronTaskType,
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index 10d1d4f346c26..a710199bf94cf 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -21,6 +21,8 @@ class JobFactory
const JOB_MODULE_ENABLE = 'setup:module:enable';
const JOB_MODULE_DISABLE = 'setup:module:disable';
const JOB_STATIC_REGENERATE = 'setup:static:regenerate';
+ const JOB_ENABLE_CACHE = 'setup:cache:enable';
+ const JOB_DISABLE_CACHE = 'setup:cache:disable';
/**
* @var ServiceLocatorInterface
@@ -128,6 +130,28 @@ public function create($name, array $params = [])
$params
);
break;
+ case self::JOB_ENABLE_CACHE:
+ return new JobSetCache(
+ $this->serviceLocator->get('Magento\Backend\Console\Command\CacheEnableCommand'),
+ $objectManagerProvider,
+ $multipleStreamOutput,
+ $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
+ $cronStatus,
+ $name,
+ $params
+ );
+ break;
+ case self::JOB_DISABLE_CACHE:
+ return new JobSetCache(
+ $this->serviceLocator->get('Magento\Backend\Console\Command\CacheDisableCommand'),
+ $objectManagerProvider,
+ $multipleStreamOutput,
+ $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
+ $cronStatus,
+ $name,
+ $params
+ );
+ break;
default:
throw new \RuntimeException(sprintf('"%s" job is not supported.', $name));
break;
diff --git a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
new file mode 100644
index 0000000000000..1047bbf6efda5
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
@@ -0,0 +1,72 @@
+command = $command;
+ $this->output = $output;
+ $this->status = $status;
+ $this->queue = $queue;
+ parent::__construct($output, $status, $objectManagerProvider, $name, $params);
+ }
+
+
+ /**
+ * Execute set cache comand
+ *
+ * @return void
+ */
+ public function execute()
+ {
+ try {
+ $this->command->run(new ArrayInput(), $this->output);
+ } catch (\Exception $e) {
+ $this->status->toggleUpdateError(true);
+ throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
+ }
+ }
+}
From c61ff33258a2a01c5af22664df2289d6761b3b31 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Fri, 1 Apr 2016 16:00:12 -0500
Subject: [PATCH 03/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- updated cache disable/enable workflow
---
setup/src/Magento/Setup/Controller/StartUpdater.php | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index 031c8914bf6b3..8f98b1e45e1ab 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -108,7 +108,10 @@ public function updateAction()
['enable' => true]
);
- if ($jobType == 'update' || $jobType == 'upgrade') {
+ if ($cronTaskType == \Magento\Setup\Model\Updater::TASK_TYPE_UPDATE
+ || $jobType == 'enable'
+ || $jobType == 'disable'
+ ) {
$errorMessage .= $this->updater->createUpdaterTask(
[],
\Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
@@ -122,6 +125,14 @@ public function updateAction()
$additionalOptions
);
+ if ($jobType == 'enable' || $jobType == 'disable') {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
+ []
+ );
+ }
+
// for module enable job types, we need to follow up with 'setup:upgrade' task to
// make sure enabled modules are properly registered
if ($jobType == 'enable') {
From 8712a8ab21e0cabe61a97afcfb1d136e315a2398 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Mon, 4 Apr 2016 10:58:49 -0500
Subject: [PATCH 04/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed JobSetCache
---
setup/src/Magento/Setup/Model/Cron/JobFactory.php | 4 ++--
setup/src/Magento/Setup/Model/Cron/JobSetCache.php | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index a710199bf94cf..d1b6b4edebf83 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -132,7 +132,7 @@ public function create($name, array $params = [])
break;
case self::JOB_ENABLE_CACHE:
return new JobSetCache(
- $this->serviceLocator->get('Magento\Backend\Console\Command\CacheEnableCommand'),
+ $objectManager->get('Magento\Backend\Console\Command\CacheEnableCommand'),
$objectManagerProvider,
$multipleStreamOutput,
$this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
@@ -143,7 +143,7 @@ public function create($name, array $params = [])
break;
case self::JOB_DISABLE_CACHE:
return new JobSetCache(
- $this->serviceLocator->get('Magento\Backend\Console\Command\CacheDisableCommand'),
+ $objectManager->get('Magento\Backend\Console\Command\CacheDisableCommand'),
$objectManagerProvider,
$multipleStreamOutput,
$this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
diff --git a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
index 1047bbf6efda5..6a01735622f56 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
@@ -63,7 +63,7 @@ public function __construct(
public function execute()
{
try {
- $this->command->run(new ArrayInput(), $this->output);
+ $this->command->run(new ArrayInput(['command' => $this->command->getName()]), $this->output);
} catch (\Exception $e) {
$this->status->toggleUpdateError(true);
throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
From 959c9b3f455b3f824314ab7ea7185e4a8bdbb267 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Mon, 4 Apr 2016 11:41:17 -0500
Subject: [PATCH 05/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed test
---
.../Console/Command/ModuleEnableDisableCommandTest.php | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
index 7001224977d1f..3118f17dfc87f 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
@@ -57,6 +57,13 @@ protected function setUp()
]));
}
+ protected function tearDown()
+ {
+ if (file_exists(BP . '/var/.regenerate')) {
+ unlink(BP . '/var/.regenerate');
+ }
+ }
+
/**
* @param bool $isEnable
* @param bool $clearStaticContent
From 7fe3ef070c9bbeed5914396c0c085e6496f3d718 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Mon, 4 Apr 2016 13:44:59 -0500
Subject: [PATCH 06/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- added test
---
.../Magento/Setup/Model/Cron/JobFactory.php | 2 -
.../Magento/Setup/Model/Cron/JobSetCache.php | 8 ---
.../Test/Unit/Controller/StartUpdaterTest.php | 12 +++++
.../Test/Unit/Model/Cron/JobFactoryTest.php | 36 +++++++++++++
.../Test/Unit/Model/Cron/JobSetCacheTest.php | 54 +++++++++++++++++++
5 files changed, 102 insertions(+), 10 deletions(-)
create mode 100644 setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index d1b6b4edebf83..38c69a9bcab50 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -135,7 +135,6 @@ public function create($name, array $params = [])
$objectManager->get('Magento\Backend\Console\Command\CacheEnableCommand'),
$objectManagerProvider,
$multipleStreamOutput,
- $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
$cronStatus,
$name,
$params
@@ -146,7 +145,6 @@ public function create($name, array $params = [])
$objectManager->get('Magento\Backend\Console\Command\CacheDisableCommand'),
$objectManagerProvider,
$multipleStreamOutput,
- $this->serviceLocator->get('Magento\Setup\Model\Cron\Queue'),
$cronStatus,
$name,
$params
diff --git a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
index 6a01735622f56..8fc28897b6096 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
@@ -24,16 +24,10 @@ class JobSetCache extends AbstractJob
*/
protected $status;
- /**
- * @var Queue
- */
- protected $queue;
-
/**
* @param \Magento\Backend\Console\Command\AbstractCacheSetCommand $command
* @param \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider
* @param \Symfony\Component\Console\Output\OutputInterface $output
- * @param Queue $queue
* @param Status $status
* @param $name
* @param array $params
@@ -42,7 +36,6 @@ public function __construct(
\Magento\Backend\Console\Command\AbstractCacheSetCommand $command,
\Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider,
\Symfony\Component\Console\Output\OutputInterface $output,
- \Magento\Setup\Model\Cron\Queue $queue,
\Magento\Setup\Model\Cron\Status $status,
$name,
$params = []
@@ -50,7 +43,6 @@ public function __construct(
$this->command = $command;
$this->output = $output;
$this->status = $status;
- $this->queue = $queue;
parent::__construct($output, $status, $objectManagerProvider, $name, $params);
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
index c07ebd79e53e9..9491d518ea230 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
@@ -157,6 +157,9 @@ public function testUpdateActionSuccessUpdate()
$write->expects($this->once())
->method('writeFile')
->with('.type.json', '{"type":"update","headerTitle":"Update package 1","titles":["A"]}');
+ $this->updater->expects($this->at(1))
+ ->method('createUpdaterTask')
+ ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
@@ -172,6 +175,9 @@ public function testUpdateActionSuccessUpgrade()
$write->expects($this->once())
->method('writeFile')
->with('.type.json', '{"type":"upgrade","headerTitle":"System Upgrade","titles":["B"]}');
+ $this->updater->expects($this->at(1))
+ ->method('createUpdaterTask')
+ ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
@@ -188,6 +194,9 @@ public function testUpdateActionSuccessEnable()
$write->expects($this->once())
->method('writeFile')
->with('.type.json', '{"type":"enable","headerTitle":"Enable Package 1","titles":["C"]}');
+ $this->updater->expects($this->at(1))
+ ->method('createUpdaterTask')
+ ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
@@ -204,6 +213,9 @@ public function testUpdateActionSuccessDisable()
$write->expects($this->once())
->method('writeFile')
->with('.type.json', '{"type":"disable","headerTitle":"Disable Package 1","titles":["D"]}');
+ $this->updater->expects($this->at(1))
+ ->method('createUpdaterTask')
+ ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
index 5048b8ad9091e..92878e324c3b4 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
@@ -167,6 +167,42 @@ public function testModuleEnable()
$this->jobFactory->create('setup:module:enable', [])
);
}
+
+ public function testCacheEnable()
+ {
+ $valueMap = [
+ [
+ 'Magento\Backend\Console\Command\CacheEnableCommand',
+ $this->getMock('Magento\Backend\Console\Command\CacheEnableCommand', [], [], '', false)
+ ]
+ ];
+ $this->objectManager->expects($this->any())
+ ->method('get')
+ ->will($this->returnValueMap($valueMap));
+
+ $this->assertInstanceOf(
+ 'Magento\Setup\Model\Cron\JobSetCache',
+ $this->jobFactory->create('setup:cache:enable', [])
+ );
+ }
+
+ public function testCacheDisable()
+ {
+ $valueMap = [
+ [
+ 'Magento\Backend\Console\Command\CacheDisableCommand',
+ $this->getMock('Magento\Backend\Console\Command\CacheDisableCommand', [], [], '', false)
+ ]
+ ];
+ $this->objectManager->expects($this->any())
+ ->method('get')
+ ->will($this->returnValueMap($valueMap));
+
+ $this->assertInstanceOf(
+ 'Magento\Setup\Model\Cron\JobSetCache',
+ $this->jobFactory->create('setup:cache:disable', [])
+ );
+ }
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php
new file mode 100644
index 0000000000000..85af3fa19a476
--- /dev/null
+++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php
@@ -0,0 +1,54 @@
+getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
+ $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface', [], '', false);
+ $cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false);
+ $cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false);
+ $valueMap = [
+ ['Magento\Framework\Module\PackageInfoFactory'],
+ ['Magento\Framework\App\State\CleanupFiles', $cleanupFiles],
+ ['Magento\Framework\App\Cache', $cache],
+ ];
+ $objectManager->expects($this->atLeastOnce())->method('get')->will($this->returnValueMap($valueMap));
+ $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
+ $output = $this->getMockForAbstractClass('Symfony\Component\Console\Output\OutputInterface', [], '', false);
+ $status = $this->getMock('Magento\Setup\Model\Cron\Status', [], [], '', false);
+ $command = $this->getMock($commandClass, [], [], '', false);
+ $command->expects($this->once())->method('getName')->willReturn($commandName);
+ $command->expects($this->once())
+ ->method('run')
+ ->with(new ArrayInput(['command' => $commandName]), $output);
+
+ $model = new JobSetCache($command, $objectManagerProvider, $output, $status, $jobName, []);
+ $model->execute();
+ }
+
+ /**
+ * @return array
+ */
+ public function setCacheDataProvider()
+ {
+ return [
+ ['Magento\Backend\Console\Command\CacheEnableCommand', 'cache:enable', 'setup:cache:enable'],
+ ['Magento\Backend\Console\Command\CacheDisableCommand', 'cache:disable', 'setup:cache:disable'],
+ ];
+ }
+}
From edf396c572cba410f4c4993c77ed0549ce4aab55 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Wed, 6 Apr 2016 16:35:05 -0500
Subject: [PATCH 07/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- updated year in docblock
---
setup/src/Magento/Setup/Model/Cron/JobSetCache.php | 2 +-
.../src/Magento/Setup/Test/Unit/Model/Cron/JobSetCacheTest.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
index 8fc28897b6096..fadbbf6ec085c 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
@@ -1,6 +1,6 @@
Date: Wed, 6 Apr 2016 17:05:18 -0500
Subject: [PATCH 08/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed Bootstrap to use constants
---
lib/internal/Magento/Framework/App/Bootstrap.php | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index ae109f237aefa..2289fd116761e 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -117,12 +117,18 @@ class Bootstrap
*/
public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null)
{
+ $defaultPaths = DirectoryList::getDefaultConfig();
if (file_exists(BP . '/var/.regenerate')) {
- $generationPath = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION])
- ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION]
- : BP . '/var/generation';
- $diPath = isset($initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI])
- ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI] : BP . '/var/di';
+ $generationPath = isset(
+ $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
+ ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
+ : BP . '/' . $defaultPaths[DirectoryList::GENERATION][DirectoryList::PATH];
+
+ $diPath = isset(
+ $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
+ ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
+ : BP . '/' . $defaultPaths[DirectoryList::DI][DirectoryList::PATH];
+
if (is_dir($generationPath)) {
\Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
}
From 7ada06036c1a0cdfa8e1de41e9567f56bdea5152 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Thu, 7 Apr 2016 10:13:43 -0500
Subject: [PATCH 09/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed code style
---
.../src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
index 92878e324c3b4..6eb8dd5c97892 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
@@ -194,9 +194,7 @@ public function testCacheDisable()
$this->getMock('Magento\Backend\Console\Command\CacheDisableCommand', [], [], '', false)
]
];
- $this->objectManager->expects($this->any())
- ->method('get')
- ->will($this->returnValueMap($valueMap));
+ $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap($valueMap));
$this->assertInstanceOf(
'Magento\Setup\Model\Cron\JobSetCache',
From 28d61b3f5093de91adcc49d9661d7c77c8c53de9 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Thu, 7 Apr 2016 11:32:23 -0500
Subject: [PATCH 10/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed code mess
---
.../Magento/Framework/App/Bootstrap.php | 44 ++++++++++++-------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index 2289fd116761e..e2c467b938e77 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -117,24 +117,8 @@ class Bootstrap
*/
public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null)
{
- $defaultPaths = DirectoryList::getDefaultConfig();
if (file_exists(BP . '/var/.regenerate')) {
- $generationPath = isset(
- $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
- ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
- : BP . '/' . $defaultPaths[DirectoryList::GENERATION][DirectoryList::PATH];
-
- $diPath = isset(
- $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
- ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
- : BP . '/' . $defaultPaths[DirectoryList::DI][DirectoryList::PATH];
-
- if (is_dir($generationPath)) {
- \Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
- }
- if (is_dir($diPath)) {
- \Magento\Framework\Filesystem\Io\File::rmdirRecursive($diPath);
- }
+ self::cleanGeneratedFiles();
unlink(BP . '/var/.regenerate');
}
self::populateAutoloader($rootDir, $initParams);
@@ -144,6 +128,32 @@ public static function create($rootDir, array $initParams, ObjectManagerFactory
return new self($factory, $rootDir, $initParams);
}
+ /**
+ * Clean generated code and DI configuration
+ *
+ * @return void
+ */
+ private static function cleanGeneratedFiles()
+ {
+ $defaultPaths = DirectoryList::getDefaultConfig();
+ $generationPath = isset(
+ $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
+ ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
+ : BP . '/' . $defaultPaths[DirectoryList::GENERATION][DirectoryList::PATH];
+
+ $diPath = isset(
+ $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
+ ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
+ : BP . '/' . $defaultPaths[DirectoryList::DI][DirectoryList::PATH];
+
+ if (is_dir($generationPath)) {
+ \Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
+ }
+ if (is_dir($diPath)) {
+ \Magento\Framework\Filesystem\Io\File::rmdirRecursive($diPath);
+ }
+ }
+
/**
* Populates autoloader with mapping info
*
From ba19d4a28dbe0cd10997f93f6fe646904f955fcf Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Thu, 7 Apr 2016 15:37:45 -0500
Subject: [PATCH 11/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed code mess
- fixed code style
- rearranged Jobs
---
.../Magento/Setup/Controller/StartUpdater.php | 114 ++++++++++--------
.../Magento/Setup/Model/Cron/JobFactory.php | 6 +-
.../Magento/Setup/Model/Cron/JobSetCache.php | 3 +-
.../Magento/Setup/Model/Cron/JobUpgrade.php | 3 +
.../Test/Unit/Model/Cron/JobFactoryTest.php | 1 -
5 files changed, 67 insertions(+), 60 deletions(-)
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index 8f98b1e45e1ab..4b829296f1660 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -94,66 +94,74 @@ public function updateAction()
) {
$errorMessage .= $this->validatePayload($postPayload);
if (empty($errorMessage)) {
- $packages = $postPayload[self::KEY_POST_PACKAGES];
- $jobType = $postPayload[self::KEY_POST_JOB_TYPE];
- $this->createTypeFlag($jobType, $postPayload[self::KEY_POST_HEADER_TITLE]);
+ $this->createUpdaterTasks($postPayload, $errorMessage);
+ }
+ } else {
+ $errorMessage .= 'Invalid request';
+ }
+ $success = empty($errorMessage) ? true : false;
+ return new JsonModel(['success' => $success, 'message' => $errorMessage]);
+ }
- $additionalOptions = [];
- $cronTaskType = '';
- $this->getCronTaskConfigInfo($jobType, $postPayload, $additionalOptions, $cronTaskType);
+ /**
+ * Create Update tasks
+ *
+ * @param array $postPayload
+ * @param string $errorMessage
+ */
+ private function createUpdaterTasks(array $postPayload, &$errorMessage)
+ {
+ $packages = $postPayload[self::KEY_POST_PACKAGES];
+ $jobType = $postPayload[self::KEY_POST_JOB_TYPE];
+ $this->createTypeFlag($jobType, $postPayload[self::KEY_POST_HEADER_TITLE]);
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
- ['enable' => true]
- );
+ $additionalOptions = [];
+ $cronTaskType = '';
+ $this->getCronTaskConfigInfo($jobType, $postPayload, $additionalOptions, $cronTaskType);
- if ($cronTaskType == \Magento\Setup\Model\Updater::TASK_TYPE_UPDATE
- || $jobType == 'enable'
- || $jobType == 'disable'
- ) {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
- []
- );
- }
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
+ ['enable' => true]
+ );
- $errorMessage .= $this->updater->createUpdaterTask(
- $packages,
- $cronTaskType,
- $additionalOptions
- );
+ if ($cronTaskType == \Magento\Setup\Model\Updater::TASK_TYPE_UPDATE
+ || $jobType == 'enable'
+ || $jobType == 'disable'
+ ) {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
+ []
+ );
+ }
- if ($jobType == 'enable' || $jobType == 'disable') {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
- []
- );
- }
+ $errorMessage .= $this->updater->createUpdaterTask(
+ $packages,
+ $cronTaskType,
+ $additionalOptions
+ );
- // for module enable job types, we need to follow up with 'setup:upgrade' task to
- // make sure enabled modules are properly registered
- if ($jobType == 'enable') {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_UPGRADE,
- []
- );
- } elseif ($jobType == 'disable') {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
- ['enable' => false]
- );
- }
- }
- } else {
- $errorMessage .= 'Invalid request';
+ // for module enable job types, we need to follow up with 'setup:upgrade' task to
+ // make sure enabled modules are properly registered
+ if ($jobType == 'enable') {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_UPGRADE,
+ []
+ );
+ } elseif ($jobType == 'disable') {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
+ ['enable' => false]
+ );
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
+ []
+ );
}
- $success = empty($errorMessage) ? true : false;
- return new JsonModel(['success' => $success, 'message' => $errorMessage]);
}
/**
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index 38c69a9bcab50..96f90a173c41e 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -136,8 +136,7 @@ public function create($name, array $params = [])
$objectManagerProvider,
$multipleStreamOutput,
$cronStatus,
- $name,
- $params
+ $name
);
break;
case self::JOB_DISABLE_CACHE:
@@ -146,8 +145,7 @@ public function create($name, array $params = [])
$objectManagerProvider,
$multipleStreamOutput,
$cronStatus,
- $name,
- $params
+ $name
);
break;
default:
diff --git a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
index fadbbf6ec085c..186634556fa01 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobSetCache.php
@@ -29,7 +29,7 @@ class JobSetCache extends AbstractJob
* @param \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param Status $status
- * @param $name
+ * @param string $name
* @param array $params
*/
public function __construct(
@@ -46,7 +46,6 @@ public function __construct(
parent::__construct($output, $status, $objectManagerProvider, $name, $params);
}
-
/**
* Execute set cache comand
*
diff --git a/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php b/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php
index 19f0668739421..f668e62adc1f8 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php
@@ -70,6 +70,9 @@ public function execute()
$this->queue->addJobs(
[['name' => \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE, 'params' => ['enable' => false]]]
);
+ $this->queue->addJobs(
+ [['name' => JobFactory::JOB_ENABLE_CACHE, 'params' => []]]
+ );
} catch (\Exception $e) {
$this->status->toggleUpdateError(true);
throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
index 6eb8dd5c97892..3dc1e97ac644d 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/Cron/JobFactoryTest.php
@@ -43,7 +43,6 @@ public function setUp()
$updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false);
$queue = $this->getMock('Magento\Setup\Model\Cron\Queue', [], [], '', false);
-
$returnValueMap = [
['Magento\Setup\Model\Updater', $updater],
['Magento\Setup\Model\Cron\Status', $status],
From a112714289aa07d7cab5b5c623b8861a288551d5 Mon Sep 17 00:00:00 2001
From: Eddie Lau
Date: Thu, 7 Apr 2016 17:43:44 -0500
Subject: [PATCH 12/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.2 to 2.1.0
- fixed code mess
- fixed code style
---
.../Magento/Setup/Controller/StartUpdater.php | 1 +
.../Magento/Setup/Model/Cron/JobFactory.php | 18 ++++--------------
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index 4b829296f1660..a861420bbece5 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -108,6 +108,7 @@ public function updateAction()
*
* @param array $postPayload
* @param string $errorMessage
+ * @return void
*/
private function createUpdaterTasks(array $postPayload, &$errorMessage)
{
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index 96f90a173c41e..dddf1b49b0e95 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -131,22 +131,12 @@ public function create($name, array $params = [])
);
break;
case self::JOB_ENABLE_CACHE:
- return new JobSetCache(
- $objectManager->get('Magento\Backend\Console\Command\CacheEnableCommand'),
- $objectManagerProvider,
- $multipleStreamOutput,
- $cronStatus,
- $name
- );
+ $cmd = $objectManager->get('Magento\Backend\Console\Command\CacheEnableCommand');
+ return new JobSetCache($cmd, $objectManagerProvider, $multipleStreamOutput, $cronStatus, $name);
break;
case self::JOB_DISABLE_CACHE:
- return new JobSetCache(
- $objectManager->get('Magento\Backend\Console\Command\CacheDisableCommand'),
- $objectManagerProvider,
- $multipleStreamOutput,
- $cronStatus,
- $name
- );
+ $cmd = $objectManager->get('Magento\Backend\Console\Command\CacheDisableCommand');
+ return new JobSetCache($cmd, $objectManagerProvider, $multipleStreamOutput, $cronStatus, $name);
break;
default:
throw new \RuntimeException(sprintf('"%s" job is not supported.', $name));
From 6a9ed8e21c98e113a34d0c42422281cba1365797 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 13:10:16 -0500
Subject: [PATCH 13/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Adding suppress warnings
---
setup/src/Magento/Setup/Model/Cron/JobFactory.php | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index dddf1b49b0e95..133d312a75f09 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -9,6 +9,7 @@
/**
* Factory class to create jobs
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class JobFactory
{
@@ -21,8 +22,6 @@ class JobFactory
const JOB_MODULE_ENABLE = 'setup:module:enable';
const JOB_MODULE_DISABLE = 'setup:module:disable';
const JOB_STATIC_REGENERATE = 'setup:static:regenerate';
- const JOB_ENABLE_CACHE = 'setup:cache:enable';
- const JOB_DISABLE_CACHE = 'setup:cache:disable';
/**
* @var ServiceLocatorInterface
@@ -130,14 +129,6 @@ public function create($name, array $params = [])
$params
);
break;
- case self::JOB_ENABLE_CACHE:
- $cmd = $objectManager->get('Magento\Backend\Console\Command\CacheEnableCommand');
- return new JobSetCache($cmd, $objectManagerProvider, $multipleStreamOutput, $cronStatus, $name);
- break;
- case self::JOB_DISABLE_CACHE:
- $cmd = $objectManager->get('Magento\Backend\Console\Command\CacheDisableCommand');
- return new JobSetCache($cmd, $objectManagerProvider, $multipleStreamOutput, $cronStatus, $name);
- break;
default:
throw new \RuntimeException(sprintf('"%s" job is not supported.', $name));
break;
From 409e113ce207951e52504379c314732dc9d5508f Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 13:37:32 -0500
Subject: [PATCH 14/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Reverting changes
---
setup/src/Magento/Setup/Model/Cron/JobFactory.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index 133d312a75f09..ef5a0c325ea43 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -22,6 +22,8 @@ class JobFactory
const JOB_MODULE_ENABLE = 'setup:module:enable';
const JOB_MODULE_DISABLE = 'setup:module:disable';
const JOB_STATIC_REGENERATE = 'setup:static:regenerate';
+ const JOB_ENABLE_CACHE = 'setup:cache:enable';
+ const JOB_DISABLE_CACHE = 'setup:cache:disable';
/**
* @var ServiceLocatorInterface
@@ -129,6 +131,14 @@ public function create($name, array $params = [])
$params
);
break;
+ case self::JOB_ENABLE_CACHE:
+ $cmd = $objectManager->get('Magento\Backend\Console\Command\CacheEnableCommand');
+ return new JobSetCache($cmd, $objectManagerProvider, $multipleStreamOutput, $cronStatus, $name);
+ break;
+ case self::JOB_DISABLE_CACHE:
+ $cmd = $objectManager->get('Magento\Backend\Console\Command\CacheDisableCommand');
+ return new JobSetCache($cmd, $objectManagerProvider, $multipleStreamOutput, $cronStatus, $name);
+ break;
default:
throw new \RuntimeException(sprintf('"%s" job is not supported.', $name));
break;
From 6dc5b9514add968d694bd356d5a50e57edc6100d Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 13:59:56 -0500
Subject: [PATCH 15/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Adding newline
---
setup/src/Magento/Setup/Model/Cron/JobFactory.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/setup/src/Magento/Setup/Model/Cron/JobFactory.php b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
index ef5a0c325ea43..863ea182aefc4 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobFactory.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobFactory.php
@@ -9,6 +9,7 @@
/**
* Factory class to create jobs
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class JobFactory
From 889522343903430119942a9ed281fc7974b5b2ac Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 16:07:45 -0500
Subject: [PATCH 16/52] MAGETWO-50846: [Github] Error in Tests unit #3715
- Fixing covers annotation and typo
---
.../Magento/Setup/Test/Unit/Controller/MarketplaceTest.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php
index 8b12be8269a32..cbfc35e9286c6 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php
@@ -113,9 +113,9 @@ public function testCheckAuthActionWithError()
}
/**
- * @covers \Magento\Setup\Controller\Marketplace::removeAuthAction
+ * @covers \Magento\Setup\Controller\Marketplace::removeCredentialsAction
*/
- public function testRemoveCredetinalsAction()
+ public function testRemoveCredentialsAction()
{
$this->marketplaceManager
->expects($this->once())
@@ -130,7 +130,7 @@ public function testRemoveCredetinalsAction()
}
/**
- * @covers \Magento\Setup\Controller\Marketplace::removeAuthAction
+ * @covers \Magento\Setup\Controller\Marketplace::removeCredentialsAction
*/
public function testRemoveCredentialsWithError()
{
From 34fc6faab81affc0a4861557534bd2a9f1733f59 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 18:21:13 -0500
Subject: [PATCH 17/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR comments
- introduced new class for regeneration of generated files and DI config
---
.../Magento/Framework/App/Bootstrap.php | 32 +-----------
.../Magento/Framework/App/GeneratedFiles.php | 43 +++++++++++++++
.../Magento/Setup/Controller/StartUpdater.php | 52 ++++++++++++-------
.../Magento/Setup/Model/Cron/JobUpgrade.php | 3 --
4 files changed, 78 insertions(+), 52 deletions(-)
create mode 100644 lib/internal/Magento/Framework/App/GeneratedFiles.php
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index e2c467b938e77..6071a0942d7a8 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -117,10 +117,8 @@ class Bootstrap
*/
public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null)
{
- if (file_exists(BP . '/var/.regenerate')) {
- self::cleanGeneratedFiles();
- unlink(BP . '/var/.regenerate');
- }
+ $generatedFiles = new GeneratedFiles();
+ $generatedFiles->requestRegeneration($initParams);
self::populateAutoloader($rootDir, $initParams);
if ($factory === null) {
$factory = self::createObjectManagerFactory($rootDir, $initParams);
@@ -128,32 +126,6 @@ public static function create($rootDir, array $initParams, ObjectManagerFactory
return new self($factory, $rootDir, $initParams);
}
- /**
- * Clean generated code and DI configuration
- *
- * @return void
- */
- private static function cleanGeneratedFiles()
- {
- $defaultPaths = DirectoryList::getDefaultConfig();
- $generationPath = isset(
- $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
- ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::GENERATION][DirectoryList::PATH]
- : BP . '/' . $defaultPaths[DirectoryList::GENERATION][DirectoryList::PATH];
-
- $diPath = isset(
- $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
- ) ? $initParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS][DirectoryList::DI][DirectoryList::PATH]
- : BP . '/' . $defaultPaths[DirectoryList::DI][DirectoryList::PATH];
-
- if (is_dir($generationPath)) {
- \Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
- }
- if (is_dir($diPath)) {
- \Magento\Framework\Filesystem\Io\File::rmdirRecursive($diPath);
- }
- }
-
/**
* Populates autoloader with mapping info
*
diff --git a/lib/internal/Magento/Framework/App/GeneratedFiles.php b/lib/internal/Magento/Framework/App/GeneratedFiles.php
new file mode 100644
index 0000000000000..5f21b12ad49c1
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/GeneratedFiles.php
@@ -0,0 +1,43 @@
+filesystem = $filesystem;
$this->navigation = $navigation;
$this->updater = $updater;
$this->moduleList = $moduleList;
+ $this->cacheManager = $cacheManager;
}
/**
@@ -94,12 +102,12 @@ public function updateAction()
) {
$errorMessage .= $this->validatePayload($postPayload);
if (empty($errorMessage)) {
- $this->createUpdaterTasks($postPayload, $errorMessage);
+ $errorMessage = $this->createUpdaterTasks($postPayload);
}
} else {
$errorMessage .= 'Invalid request';
}
- $success = empty($errorMessage) ? true : false;
+ $success = empty($errorMessage);
return new JsonModel(['success' => $success, 'message' => $errorMessage]);
}
@@ -107,11 +115,11 @@ public function updateAction()
* Create Update tasks
*
* @param array $postPayload
- * @param string $errorMessage
- * @return void
+ * @return string
*/
- private function createUpdaterTasks(array $postPayload, &$errorMessage)
+ private function createUpdaterTasks(array $postPayload)
{
+ $errorMessage = '';
$packages = $postPayload[self::KEY_POST_PACKAGES];
$jobType = $postPayload[self::KEY_POST_JOB_TYPE];
$this->createTypeFlag($jobType, $postPayload[self::KEY_POST_HEADER_TITLE]);
@@ -126,16 +134,11 @@ private function createUpdaterTasks(array $postPayload, &$errorMessage)
['enable' => true]
);
- if ($cronTaskType == \Magento\Setup\Model\Updater::TASK_TYPE_UPDATE
- || $jobType == 'enable'
- || $jobType == 'disable'
- ) {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
- []
- );
- }
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
+ []
+ );
$errorMessage .= $this->updater->createUpdaterTask(
$packages,
@@ -157,12 +160,23 @@ private function createUpdaterTasks(array $postPayload, &$errorMessage)
\Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
['enable' => false]
);
- $errorMessage .= $this->updater->createUpdaterTask(
+ }
+
+ $cacheStatus = $this->cacheManager-getStatus();
+ $enabledCaches = [];
+ foreach ($cacheStatus as $cacheName => $value) {
+ if ($value) {
+ $enabledCaches[] = $cacheName;
+ }
+ }
+
+ $errorMessage .= $this->updater->createUpdaterTask(
[],
\Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
- []
+ [implode(' ', $enabledCaches)]
);
- }
+
+ return $errorMessage;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php b/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php
index f668e62adc1f8..19f0668739421 100644
--- a/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php
+++ b/setup/src/Magento/Setup/Model/Cron/JobUpgrade.php
@@ -70,9 +70,6 @@ public function execute()
$this->queue->addJobs(
[['name' => \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE, 'params' => ['enable' => false]]]
);
- $this->queue->addJobs(
- [['name' => JobFactory::JOB_ENABLE_CACHE, 'params' => []]]
- );
} catch (\Exception $e) {
$this->status->toggleUpdateError(true);
throw new \RuntimeException(sprintf('Could not complete %s successfully: %s', $this, $e->getMessage()));
From 4acd9de1c1aef05ccf0b3d99d3bf706d1af48dcc Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 18:42:54 -0500
Subject: [PATCH 18/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Static fixes
---
.../Magento/Framework/App/GeneratedFiles.php | 50 +++++++++----------
.../Magento/Setup/Controller/StartUpdater.php | 8 +--
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/GeneratedFiles.php b/lib/internal/Magento/Framework/App/GeneratedFiles.php
index 5f21b12ad49c1..6dbcb1c8ce78d 100644
--- a/lib/internal/Magento/Framework/App/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/App/GeneratedFiles.php
@@ -12,32 +12,32 @@
*/
class GeneratedFiles
{
- /**
- * Separator literal to assemble timer identifier from timer names
- */
- const REGENERATE_FLAG = '/var/.regenerate';
+ /**
+ * Separator literal to assemble timer identifier from timer names
+ */
+ const REGENERATE_FLAG = '/var/.regenerate';
- /**
- * Clean generated code and DI configuration
- *
- * @param array $initParams
- * @return void
- */
- public function requestRegeneration($initParams)
- {
- if (file_exists(BP . self::REGENERATE_FLAG)) {
- $directoryList = new DirectoryList(BP, $initParams);
- $defaultPaths = $directoryList::getDefaultConfig();
- $generationPath = BP . '/' . $defaultPaths[DirectoryList::GENERATION][DirectoryList::PATH];
- $diPath = BP . '/' . $defaultPaths[DirectoryList::DI][DirectoryList::PATH];
+ /**
+ * Clean generated code and DI configuration
+ *
+ * @param array $initParams
+ * @return void
+ */
+ public function requestRegeneration($initParams)
+ {
+ if (file_exists(BP . self::REGENERATE_FLAG)) {
+ $directoryList = new DirectoryList(BP, $initParams);
+ $defaultPaths = $directoryList::getDefaultConfig();
+ $generationPath = BP . '/' . $defaultPaths[DirectoryList::GENERATION][DirectoryList::PATH];
+ $diPath = BP . '/' . $defaultPaths[DirectoryList::DI][DirectoryList::PATH];
- if (is_dir($generationPath)) {
- \Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
+ if (is_dir($generationPath)) {
+ \Magento\Framework\Filesystem\Io\File::rmdirRecursive($generationPath);
}
- if (is_dir($diPath)) {
- \Magento\Framework\Filesystem\Io\File::rmdirRecursive($diPath);
- }
- unlink(BP . self::REGENERATE_FLAG);
- }
- }
+ if (is_dir($diPath)) {
+ \Magento\Framework\Filesystem\Io\File::rmdirRecursive($diPath);
+ }
+ unlink(BP . self::REGENERATE_FLAG);
+ }
+ }
}
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index 3c3a09bd95116..6ba3a31defcb2 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -171,10 +171,10 @@ private function createUpdaterTasks(array $postPayload)
}
$errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
- [implode(' ', $enabledCaches)]
- );
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
+ [implode(' ', $enabledCaches)]
+ );
return $errorMessage;
}
From 454c5fc9e573db47c8c84e906fc2662968e6563c Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 19:22:34 -0500
Subject: [PATCH 19/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- PHPMD coupling fix
---
.../Magento/Setup/Controller/StartUpdater.php | 280 ++----------------
.../Magento/Setup/Model/PayloadValidator.php | 113 +++++++
.../Setup/Model/UpdaterTaskCreator.php | 197 ++++++++++++
3 files changed, 328 insertions(+), 262 deletions(-)
create mode 100644 setup/src/Magento/Setup/Model/PayloadValidator.php
create mode 100644 setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index 6ba3a31defcb2..d043d317da7d7 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -6,9 +6,7 @@
namespace Magento\Setup\Controller;
-use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Setup\Model\Cron\JobComponentUninstall;
-use Zend\Json\Json;
+use Magento\Setup\Model\UpdaterTaskCreator;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
use Zend\View\Model\ViewModel;
@@ -18,61 +16,28 @@
*/
class StartUpdater extends AbstractActionController
{
- /**#@+
- * Keys in Post payload
- */
- const KEY_POST_JOB_TYPE = 'type';
- const KEY_POST_PACKAGES = 'packages';
- const KEY_POST_HEADER_TITLE = 'headerTitle';
- const KEY_POST_DATA_OPTION = 'dataOption';
- const KEY_POST_PACKAGE_NAME = 'name';
- const KEY_POST_PACKAGE_VERSION = 'version';
- /**#@- */
-
- /**
- * @var \Magento\Framework\Filesystem
- */
- private $filesystem;
-
- /**
- * @var \Magento\Setup\Model\Navigation
- */
- private $navigation;
-
- /**
- * @var \Magento\Setup\Model\Updater
- */
- private $updater;
-
/**
- * @var \Magento\Framework\Module\FullModuleList
+ * @var \Magento\Setup\Model\UpdaterTaskCreator
*/
- private $moduleList;
+ private $updaterTaskCreator;
/**
- * @var \Magento\Framework\App\Cache\Manager
+ * @var \Magento\Setup\Model\PayloadValidator
*/
- private $cacheManager;
+ private $payloadValidator;
/**
- * @param \Magento\Framework\Filesystem $filesystem
- * @param \Magento\Setup\Model\Navigation $navigation
- * @param \Magento\Setup\Model\Updater $updater
- * @param \Magento\Framework\Module\FullModuleList $moduleList
- * @param \Magento\Framework\App\Cache\Manager $cacheManager
+ * Constructor
+ *
+ * @param \Magento\Setup\Model\UpdaterTaskCreator $updaterTaskCreator
+ * @param \Magento\Setup\Model\PayloadValidator $payloadValidator
*/
public function __construct(
- \Magento\Framework\Filesystem $filesystem,
- \Magento\Setup\Model\Navigation $navigation,
- \Magento\Setup\Model\Updater $updater,
- \Magento\Framework\Module\FullModuleList $moduleList,
- \Magento\Framework\App\Cache\Manager $cacheManager
+ \Magento\Setup\Model\UpdaterTaskCreator $updaterTaskCreator,
+ \Magento\Setup\Model\PayloadValidator $payloadValidator
) {
- $this->filesystem = $filesystem;
- $this->navigation = $navigation;
- $this->updater = $updater;
- $this->moduleList = $moduleList;
- $this->cacheManager = $cacheManager;
+ $this->updaterTaskCreator = $updaterTaskCreator;
+ $this->payloadValidator = $payloadValidator;
}
/**
@@ -96,13 +61,13 @@ public function updateAction()
{
$postPayload = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
$errorMessage = '';
- if (isset($postPayload[self::KEY_POST_PACKAGES])
- && is_array($postPayload[self::KEY_POST_PACKAGES])
- && isset($postPayload[self::KEY_POST_JOB_TYPE])
+ if (isset($postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES])
+ && is_array($postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES])
+ && isset($postPayload[UpdaterTaskCreator::KEY_POST_JOB_TYPE])
) {
- $errorMessage .= $this->validatePayload($postPayload);
+ $errorMessage .= $this->payloadValidator->validatePayload($postPayload);
if (empty($errorMessage)) {
- $errorMessage = $this->createUpdaterTasks($postPayload);
+ $errorMessage = $this->updaterTaskCreator->createUpdaterTasks($postPayload);
}
} else {
$errorMessage .= 'Invalid request';
@@ -110,213 +75,4 @@ public function updateAction()
$success = empty($errorMessage);
return new JsonModel(['success' => $success, 'message' => $errorMessage]);
}
-
- /**
- * Create Update tasks
- *
- * @param array $postPayload
- * @return string
- */
- private function createUpdaterTasks(array $postPayload)
- {
- $errorMessage = '';
- $packages = $postPayload[self::KEY_POST_PACKAGES];
- $jobType = $postPayload[self::KEY_POST_JOB_TYPE];
- $this->createTypeFlag($jobType, $postPayload[self::KEY_POST_HEADER_TITLE]);
-
- $additionalOptions = [];
- $cronTaskType = '';
- $this->getCronTaskConfigInfo($jobType, $postPayload, $additionalOptions, $cronTaskType);
-
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
- ['enable' => true]
- );
-
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
- []
- );
-
- $errorMessage .= $this->updater->createUpdaterTask(
- $packages,
- $cronTaskType,
- $additionalOptions
- );
-
- // for module enable job types, we need to follow up with 'setup:upgrade' task to
- // make sure enabled modules are properly registered
- if ($jobType == 'enable') {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_UPGRADE,
- []
- );
- } elseif ($jobType == 'disable') {
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
- ['enable' => false]
- );
- }
-
- $cacheStatus = $this->cacheManager-getStatus();
- $enabledCaches = [];
- foreach ($cacheStatus as $cacheName => $value) {
- if ($value) {
- $enabledCaches[] = $cacheName;
- }
- }
-
- $errorMessage .= $this->updater->createUpdaterTask(
- [],
- \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
- [implode(' ', $enabledCaches)]
- );
-
- return $errorMessage;
- }
-
- /**
- * Validate POST request payload
- *
- * @param array $postPayload
- * @return string
- */
- private function validatePayload(array $postPayload)
- {
- $jobType = $postPayload[self::KEY_POST_JOB_TYPE];
- $errorMessage = '';
- switch($jobType) {
- case 'uninstall':
- $errorMessage = $this->validateUninstallPayload($postPayload);
- break;
-
- case 'update':
- $errorMessage = $this->validateUpdatePayload($postPayload);
- break;
-
- case 'enable':
- case 'disable':
- $errorMessage = $this->validateEnableDisablePayload($postPayload);
- break;
- }
- return $errorMessage;
- }
-
- /**
- * Validate 'uninstall' job type payload
- *
- * @param array $postPayload
- * @return string
- */
- private function validateUninstallPayload(array $postPayload)
- {
- $errorMessage = '';
- if (!isset($postPayload[self::KEY_POST_DATA_OPTION])) {
- $errorMessage = 'Missing dataOption' . PHP_EOL;
- }
- return $errorMessage;
- }
-
- /**
- * Validate 'update' job type payload
- *
- * @param array $postPayload
- * @return string
- */
- private function validateUpdatePayload(array $postPayload)
- {
- $errorMessage = '';
- $packages = $postPayload[self::KEY_POST_PACKAGES];
- foreach ($packages as $package) {
- if ((!isset($package[self::KEY_POST_PACKAGE_NAME])) || (!isset($package[self::KEY_POST_PACKAGE_VERSION]))) {
- $errorMessage .= 'Missing package information' . PHP_EOL;
- break;
- }
- }
- return $errorMessage;
- }
-
- /**
- * Validate 'enable/disable' job type payload
- *
- * @param array $postPayload
- * @return string
- */
- private function validateEnableDisablePayload(array $postPayload)
- {
- $errorMessage = '';
- $packages = $postPayload[self::KEY_POST_PACKAGES];
- foreach ($packages as $package) {
- if (!$this->moduleList->has($package[self::KEY_POST_PACKAGE_NAME])) {
- $errorMessage .= 'Invalid Magento module name: ' . $package[self::KEY_POST_PACKAGE_NAME] . PHP_EOL;
- break;
- }
- }
- return $errorMessage;
- }
-
- /**
- * Create flag to be used in Updater
- *
- * @param string $type
- * @param string $title
- * @return void
- */
- private function createTypeFlag($type, $title)
- {
- $data = [];
- $data[self::KEY_POST_JOB_TYPE] = $type;
- $data[self::KEY_POST_HEADER_TITLE] = $title;
-
- $menuItems = $this->navigation->getMenuItems();
- $titles = [];
- foreach ($menuItems as $menuItem) {
- if (isset($menuItem['type']) && $menuItem['type'] === $type) {
- $titles[] = str_replace("\n", '
', $menuItem['title']);
- }
- }
- $data['titles'] = $titles;
- $directoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
- $directoryWrite->writeFile('.type.json', Json::encode($data));
- }
-
- /**
- * Returns cron config info based on passed in job type
- *
- * @param string $jobType
- * @param array $postPayload
- * @param array $addtionalOptions
- * @param string $cronTaskType
- * @return void
- */
- private function getCronTaskConfigInfo($jobType, $postPayload, &$additionalOptions, &$cronTaskType)
- {
- $additionalOptions = [];
- switch($jobType) {
- case 'uninstall':
- $additionalOptions = [
- JobComponentUninstall::DATA_OPTION => $postPayload[self::KEY_POST_DATA_OPTION]
- ];
- $cronTaskType = \Magento\Setup\Model\Cron\JobFactory::JOB_COMPONENT_UNINSTALL;
- break;
-
- case 'upgrade':
- case 'update':
- case 'install':
- $cronTaskType = \Magento\Setup\Model\Updater::TASK_TYPE_UPDATE;
- break;
-
- case 'enable':
- $cronTaskType = \Magento\Setup\Model\Cron\JobFactory::JOB_MODULE_ENABLE;
- break;
-
- case 'disable':
- $cronTaskType = \Magento\Setup\Model\Cron\JobFactory::JOB_MODULE_DISABLE;
- break;
- }
- }
}
diff --git a/setup/src/Magento/Setup/Model/PayloadValidator.php b/setup/src/Magento/Setup/Model/PayloadValidator.php
new file mode 100644
index 0000000000000..796d7d6db874a
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/PayloadValidator.php
@@ -0,0 +1,113 @@
+moduleList = $moduleList;
+ }
+
+ /**
+ * Validate POST request payload
+ *
+ * @param array $postPayload
+ * @return string
+ */
+ public function validatePayload(array $postPayload)
+ {
+ $jobType = $postPayload[UpdaterTaskCreator::KEY_POST_JOB_TYPE];
+ $errorMessage = '';
+ switch($jobType) {
+ case 'uninstall':
+ $errorMessage = $this->validateUninstallPayload($postPayload);
+ break;
+
+ case 'update':
+ $errorMessage = $this->validateUpdatePayload($postPayload);
+ break;
+
+ case 'enable':
+ case 'disable':
+ $errorMessage = $this->validateEnableDisablePayload($postPayload);
+ break;
+ }
+ return $errorMessage;
+ }
+
+ /**
+ * Validate 'uninstall' job type payload
+ *
+ * @param array $postPayload
+ * @return string
+ */
+ private function validateUninstallPayload(array $postPayload)
+ {
+ $errorMessage = '';
+ if (!isset($postPayload[UpdaterTaskCreator::KEY_POST_DATA_OPTION])) {
+ $errorMessage = 'Missing dataOption' . PHP_EOL;
+ }
+ return $errorMessage;
+ }
+
+ /**
+ * Validate 'update' job type payload
+ *
+ * @param array $postPayload
+ * @return string
+ */
+ private function validateUpdatePayload(array $postPayload)
+ {
+ $errorMessage = '';
+ $packages = $postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES];
+ foreach ($packages as $package) {
+ if ((!isset($package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME]))
+ || (!isset($package[UpdaterTaskCreator::KEY_POST_PACKAGE_VERSION]))) {
+ $errorMessage .= 'Missing package information' . PHP_EOL;
+ break;
+ }
+ }
+ return $errorMessage;
+ }
+
+ /**
+ * Validate 'enable/disable' job type payload
+ *
+ * @param array $postPayload
+ * @return string
+ */
+ private function validateEnableDisablePayload(array $postPayload)
+ {
+ $errorMessage = '';
+ $packages = $postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES];
+ foreach ($packages as $package) {
+ if (!$this->moduleList->has($package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME])) {
+ $errorMessage .= 'Invalid Magento module name: ' . $package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME]
+ . PHP_EOL;
+ break;
+ }
+ }
+ return $errorMessage;
+ }
+}
\ No newline at end of file
diff --git a/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php b/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
new file mode 100644
index 0000000000000..eab70cf30d660
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
@@ -0,0 +1,197 @@
+filesystem = $filesystem;
+ $this->navigation = $navigation;
+ $this->updater = $updater;
+ $this->cacheManager = $cacheManager;
+ }
+
+ /**
+ * Create flag to be used in Updater
+ *
+ * @param string $type
+ * @param string $title
+ * @return void
+ */
+ private function createTypeFlag($type, $title)
+ {
+ $data = [];
+ $data[self::KEY_POST_JOB_TYPE] = $type;
+ $data[self::KEY_POST_HEADER_TITLE] = $title;
+
+ $menuItems = $this->navigation->getMenuItems();
+ $titles = [];
+ foreach ($menuItems as $menuItem) {
+ if (isset($menuItem['type']) && $menuItem['type'] === $type) {
+ $titles[] = str_replace("\n", '
', $menuItem['title']);
+ }
+ }
+ $data['titles'] = $titles;
+ $directoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $directoryWrite->writeFile('.type.json', Json::encode($data));
+ }
+
+ /**
+ * Create Update tasks
+ *
+ * @param array $postPayload
+ * @return string
+ */
+ public function createUpdaterTasks(array $postPayload)
+ {
+ $errorMessage = '';
+ $packages = $postPayload[self::KEY_POST_PACKAGES];
+ $jobType = $postPayload[self::KEY_POST_JOB_TYPE];
+ $this->createTypeFlag($jobType, $postPayload[self::KEY_POST_HEADER_TITLE]);
+
+ $additionalOptions = [];
+ $cronTaskType = '';
+ $this->getCronTaskConfigInfo($jobType, $postPayload, $additionalOptions, $cronTaskType);
+
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
+ ['enable' => true]
+ );
+
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
+ []
+ );
+
+ $errorMessage .= $this->updater->createUpdaterTask(
+ $packages,
+ $cronTaskType,
+ $additionalOptions
+ );
+
+ // for module enable job types, we need to follow up with 'setup:upgrade' task to
+ // make sure enabled modules are properly registered
+ if ($jobType == 'enable') {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_UPGRADE,
+ []
+ );
+ } elseif ($jobType == 'disable') {
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Updater::TASK_TYPE_MAINTENANCE_MODE,
+ ['enable' => false]
+ );
+ }
+
+ $cacheStatus = $this->cacheManager->getStatus();
+ $enabledCaches = [];
+ foreach ($cacheStatus as $cacheName => $value) {
+ if ($value) {
+ $enabledCaches[] = $cacheName;
+ }
+ }
+
+ $errorMessage .= $this->updater->createUpdaterTask(
+ [],
+ \Magento\Setup\Model\Cron\JobFactory::JOB_ENABLE_CACHE,
+ [implode(' ', $enabledCaches)]
+ );
+
+ return $errorMessage;
+ }
+
+ /**
+ * Returns cron config info based on passed in job type
+ *
+ * @param string $jobType
+ * @param array $postPayload
+ * @param array $addtionalOptions
+ * @param string $cronTaskType
+ * @return void
+ */
+ private function getCronTaskConfigInfo($jobType, $postPayload, &$additionalOptions, &$cronTaskType)
+ {
+ $additionalOptions = [];
+ switch($jobType) {
+ case 'uninstall':
+ $additionalOptions = [
+ JobComponentUninstall::DATA_OPTION => $postPayload[self::KEY_POST_DATA_OPTION]
+ ];
+ $cronTaskType = \Magento\Setup\Model\Cron\JobFactory::JOB_COMPONENT_UNINSTALL;
+ break;
+
+ case 'upgrade':
+ case 'update':
+ case 'install':
+ $cronTaskType = \Magento\Setup\Model\Updater::TASK_TYPE_UPDATE;
+ break;
+
+ case 'enable':
+ $cronTaskType = \Magento\Setup\Model\Cron\JobFactory::JOB_MODULE_ENABLE;
+ break;
+
+ case 'disable':
+ $cronTaskType = \Magento\Setup\Model\Cron\JobFactory::JOB_MODULE_DISABLE;
+ break;
+ }
+ }
+}
\ No newline at end of file
From da152bba4998cb47d39603586fc64ff67dfdf3bf Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 8 Apr 2016 19:45:13 -0500
Subject: [PATCH 20/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR comments
---
.../Magento/Framework/App/Bootstrap.php | 1 +
.../Magento/Framework/App/GeneratedFiles.php | 43 -----------
.../Magento/Framework/Code/GeneratedFiles.php | 75 +++++++++++++++++++
.../Command/AbstractModuleManageCommand.php | 14 +++-
4 files changed, 89 insertions(+), 44 deletions(-)
delete mode 100644 lib/internal/Magento/Framework/App/GeneratedFiles.php
create mode 100644 lib/internal/Magento/Framework/Code/GeneratedFiles.php
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index 6071a0942d7a8..3bae4fadc28a6 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -10,6 +10,7 @@
use Magento\Framework\AppInterface;
use Magento\Framework\Autoload\AutoloaderRegistry;
use Magento\Framework\Autoload\Populator;
+use Magento\Framework\Code\GeneratedFiles;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Profiler;
diff --git a/lib/internal/Magento/Framework/App/GeneratedFiles.php b/lib/internal/Magento/Framework/App/GeneratedFiles.php
deleted file mode 100644
index 6dbcb1c8ce78d..0000000000000
--- a/lib/internal/Magento/Framework/App/GeneratedFiles.php
+++ /dev/null
@@ -1,43 +0,0 @@
-readInterface = $readInterface;
+ $this->file = $file;
+ }
+
+ /**
+ * Clean generated code and DI configuration
+ *
+ * @param array $initParams
+ * @return void
+ */
+ public function requestRegeneration($initParams)
+ {
+ if (file_exists(BP . self::REGENERATE_FLAG)) {
+ $directoryList = new DirectoryList(BP, $initParams);
+ $generationPath = BP . '/' . $directoryList->getPath(DirectoryList::GENERATION);
+ $diPath = BP . '/' . $directoryList->getPath(DirectoryList::DI);
+
+ if ($this->readInterface->isDirectory($generationPath)) {
+ $this->file->deleteDirectory($generationPath, true);
+ }
+ if ($this->readInterface->isDirectory($diPath)) {
+ $this->file->deleteDirectory($diPath, true);
+ }
+ unlink(BP . self::REGENERATE_FLAG);
+ }
+ }
+
+ /**
+ * Create flag for regeneration of code and di
+ *
+ * @throws \Magento\Framework\Exception\FileSystemException
+ */
+ public function createRequestForRegeneration()
+ {
+ $this->file->touch(BP . '/var/.regenerate');
+ }
+}
diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
index 97836010db02c..df4940c97ac04 100644
--- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Setup\Console\Command;
+use Magento\Framework\Code\GeneratedFiles;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -17,6 +18,17 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand
const INPUT_KEY_ALL = 'all';
const INPUT_KEY_FORCE = 'force';
+ /**
+ * @var GeneratedFiles
+ */
+ private $generatedFiles;
+
+ public function __construct(GeneratedFiles $generatedFiles)
+ {
+ $this->generatedFiles = $generatedFiles;
+ parent::__construct();
+ }
+
/**
* {@inheritdoc}
*/
@@ -102,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$this->cleanup($input, $output);
- touch(BP . '/var/.regenerate');
+ $this->generatedFiles->createRequestForRegeneration();
if ($force) {
$output->writeln(
From c010eb2d7034dbd876d570d34d43270b5aff3594 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 11 Apr 2016 08:08:40 -0500
Subject: [PATCH 21/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR comments
---
.../Setup/Console/Command/AbstractModuleManageCommand.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
index df4940c97ac04..56b6d130ee153 100644
--- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
@@ -23,6 +23,11 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand
*/
private $generatedFiles;
+ /**
+ * Constructor
+ *
+ * @param GeneratedFiles $generatedFiles
+ */
public function __construct(GeneratedFiles $generatedFiles)
{
$this->generatedFiles = $generatedFiles;
From 2709283f233ad4c694f9d2fd38a999fc8921247c Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 11 Apr 2016 10:45:45 -0500
Subject: [PATCH 22/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR comments
---
.../Magento/Framework/App/Bootstrap.php | 3 --
.../Framework/App/ObjectManagerFactory.php | 4 ++
.../Magento/Framework/Code/GeneratedFiles.php | 54 ++++++++++---------
.../Command/AbstractModuleManageCommand.php | 6 ++-
4 files changed, 37 insertions(+), 30 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index 3bae4fadc28a6..6658b099c1204 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -10,7 +10,6 @@
use Magento\Framework\AppInterface;
use Magento\Framework\Autoload\AutoloaderRegistry;
use Magento\Framework\Autoload\Populator;
-use Magento\Framework\Code\GeneratedFiles;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Profiler;
@@ -118,8 +117,6 @@ class Bootstrap
*/
public static function create($rootDir, array $initParams, ObjectManagerFactory $factory = null)
{
- $generatedFiles = new GeneratedFiles();
- $generatedFiles->requestRegeneration($initParams);
self::populateAutoloader($rootDir, $initParams);
if ($factory === null) {
$factory = self::createObjectManagerFactory($rootDir, $initParams);
diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
index 86ba41cc08132..da4d0af944ed0 100644
--- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
+++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
@@ -13,6 +13,7 @@
use Magento\Framework\ObjectManager\Definition\Compiled\Serialized;
use Magento\Framework\App\ObjectManager\Environment;
use Magento\Framework\Config\File\ConfigFilePool;
+use Magento\Framework\Code\GeneratedFiles;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -108,6 +109,9 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool
*/
public function create(array $arguments)
{
+ $generatedFiles = new GeneratedFiles($this->directoryList, $this->driverPool);
+ $generatedFiles->requestRegeneration();
+
$deploymentConfig = $this->createDeploymentConfig($this->directoryList, $this->configFilePool, $arguments);
$arguments = array_merge($deploymentConfig->get(), $arguments);
$definitionFactory = new \Magento\Framework\ObjectManager\DefinitionFactory(
diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
index d94b6368a1e52..cc605672e18fa 100644
--- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
@@ -6,8 +6,9 @@
namespace Magento\Framework\Code;
use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\Filesystem\Directory\ReadInterface;
-use Magento\Framework\Filesystem\Driver\File;
+use Magento\Framework\Filesystem\DriverPool;
+use Magento\Framework\Filesystem\Directory\WriteFactory;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
/**
* Regenerates generated code and DI configuration
@@ -20,56 +21,59 @@ class GeneratedFiles
const REGENERATE_FLAG = '/var/.regenerate';
/**
- * @var ReadInterface
+ * @var WriteFactory
*/
- private $readInterface;
+ private $writeFactory;
/**
- * @var File
+ * @var DirectoryList
*/
- private $file;
+ private $directoryList;
+
+ /**
+ * @var WriteInterface
+ */
+ private $writeInterface;
/**
* Constructor
*
- * @param ReadInterface $readInterface
- * @param File $file
+ * @param DirectoryList $directoryList
+ * @param DriverPool $driverPool
*/
- public function __construct(ReadInterface $readInterface, File $file) {
- $this->readInterface = $readInterface;
- $this->file = $file;
+ public function __construct(DirectoryList $directoryList, DriverPool $driverPool) {
+ $this->directoryList = $directoryList;
+ $this->writeFactory = new WriteFactory($driverPool);
}
/**
* Clean generated code and DI configuration
*
- * @param array $initParams
* @return void
*/
- public function requestRegeneration($initParams)
+ public function requestRegeneration()
{
- if (file_exists(BP . self::REGENERATE_FLAG)) {
- $directoryList = new DirectoryList(BP, $initParams);
- $generationPath = BP . '/' . $directoryList->getPath(DirectoryList::GENERATION);
- $diPath = BP . '/' . $directoryList->getPath(DirectoryList::DI);
+ $this->writeInterface = $this->writeFactory->create(BP);
- if ($this->readInterface->isDirectory($generationPath)) {
- $this->file->deleteDirectory($generationPath, true);
+ if ($this->writeInterface->isExist(BP . self::REGENERATE_FLAG)) {
+ $generationPath = BP . '/' . $this->directoryList->getPath(DirectoryList::GENERATION);
+ $diPath = BP . '/' . $this->directoryList->getPath(DirectoryList::DI);
+
+ if ($this->writeInterface->isDirectory($generationPath)) {
+ $this->writeInterface->delete($generationPath);
}
- if ($this->readInterface->isDirectory($diPath)) {
- $this->file->deleteDirectory($diPath, true);
+ if ($this->writeInterface->isDirectory($diPath)) {
+ $this->writeInterface->delete($diPath);
}
- unlink(BP . self::REGENERATE_FLAG);
+ $this->writeInterface->delete(BP . self::REGENERATE_FLAG);
}
}
/**
* Create flag for regeneration of code and di
- *
- * @throws \Magento\Framework\Exception\FileSystemException
*/
public function createRequestForRegeneration()
{
- $this->file->touch(BP . '/var/.regenerate');
+ $this->writeInterface->touch(BP . '/var/.regenerate');
}
}
diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
index 56b6d130ee153..725094e7cd0f3 100644
--- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Console\Command;
use Magento\Framework\Code\GeneratedFiles;
+use Magento\Setup\Model\ObjectManagerProvider;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -27,11 +28,12 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand
* Constructor
*
* @param GeneratedFiles $generatedFiles
+ * @param ObjectManagerProvider $objectManagerProvider
*/
- public function __construct(GeneratedFiles $generatedFiles)
+ public function __construct(GeneratedFiles $generatedFiles,ObjectManagerProvider $objectManagerProvider)
{
$this->generatedFiles = $generatedFiles;
- parent::__construct();
+ parent::__construct($objectManagerProvider);
}
/**
From 75d23a49ecb7be5e147e233fa88553f493cb0f33 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 11 Apr 2016 16:21:24 -0500
Subject: [PATCH 23/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR comments
- Adding unit tests
---
.../Framework/App/ObjectManagerFactory.php | 5 +-
.../Magento/Framework/Code/GeneratedFiles.php | 34 ++--
.../Code/Test/Unit/GeneratedFilesTest.php | 110 +++++++++++
.../Command/AbstractModuleManageCommand.php | 4 +-
.../Magento/Setup/Controller/StartUpdater.php | 1 +
.../Magento/Setup/Model/PayloadValidator.php | 41 ++--
.../Setup/Model/UpdaterTaskCreator.php | 4 +-
.../ModuleEnableDisableCommandTest.php | 46 +++--
.../Test/Unit/Controller/StartUpdaterTest.php | 179 ++++--------------
.../Test/Unit/Model/PayloadValidatorTest.php | 91 +++++++++
.../Unit/Model/UpdaterTaskCreatorTest.php | 86 +++++++++
11 files changed, 394 insertions(+), 207 deletions(-)
create mode 100644 lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
create mode 100644 setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php
create mode 100644 setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php
diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
index da4d0af944ed0..4319bf9f9861b 100644
--- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
+++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
@@ -109,8 +109,9 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool
*/
public function create(array $arguments)
{
- $generatedFiles = new GeneratedFiles($this->directoryList, $this->driverPool);
- $generatedFiles->requestRegeneration();
+ $writeFactory = new \Magento\Framework\Filesystem\Directory\WriteFactory($this->driverPool);
+ $generatedFiles = new GeneratedFiles($this->directoryList, $writeFactory);
+ $generatedFiles->regenerate();
$deploymentConfig = $this->createDeploymentConfig($this->directoryList, $this->configFilePool, $arguments);
$arguments = array_merge($deploymentConfig->get(), $arguments);
diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
index cc605672e18fa..ce2cd3ca49d97 100644
--- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
@@ -6,7 +6,6 @@
namespace Magento\Framework\Code;
use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\Directory\WriteFactory;
use Magento\Framework\Filesystem\Directory\WriteInterface;
@@ -20,11 +19,6 @@ class GeneratedFiles
*/
const REGENERATE_FLAG = '/var/.regenerate';
- /**
- * @var WriteFactory
- */
- private $writeFactory;
-
/**
* @var DirectoryList
*/
@@ -33,17 +27,17 @@ class GeneratedFiles
/**
* @var WriteInterface
*/
- private $writeInterface;
+ private $write;
/**
* Constructor
*
* @param DirectoryList $directoryList
- * @param DriverPool $driverPool
+ * @param WriteFactory $writeFactory
*/
- public function __construct(DirectoryList $directoryList, DriverPool $driverPool) {
+ public function __construct(DirectoryList $directoryList, WriteFactory $writeFactory) {
$this->directoryList = $directoryList;
- $this->writeFactory = new WriteFactory($driverPool);
+ $this->write = $writeFactory->create(BP);
}
/**
@@ -51,29 +45,27 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool
*
* @return void
*/
- public function requestRegeneration()
+ public function regenerate()
{
- $this->writeInterface = $this->writeFactory->create(BP);
-
- if ($this->writeInterface->isExist(BP . self::REGENERATE_FLAG)) {
+ if ($this->write->isExist(self::REGENERATE_FLAG)) {
$generationPath = BP . '/' . $this->directoryList->getPath(DirectoryList::GENERATION);
$diPath = BP . '/' . $this->directoryList->getPath(DirectoryList::DI);
- if ($this->writeInterface->isDirectory($generationPath)) {
- $this->writeInterface->delete($generationPath);
+ if ($this->write->isDirectory($generationPath)) {
+ $this->write->delete($generationPath);
}
- if ($this->writeInterface->isDirectory($diPath)) {
- $this->writeInterface->delete($diPath);
+ if ($this->write->isDirectory($diPath)) {
+ $this->write->delete($diPath);
}
- $this->writeInterface->delete(BP . self::REGENERATE_FLAG);
+ $this->write->delete(BP . self::REGENERATE_FLAG);
}
}
/**
* Create flag for regeneration of code and di
*/
- public function createRequestForRegeneration()
+ public function requestRegeneration()
{
- $this->writeInterface->touch(BP . '/var/.regenerate');
+ $this->write->touch(BP . '/var/.regenerate');
}
}
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
new file mode 100644
index 0000000000000..44845354687b7
--- /dev/null
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
@@ -0,0 +1,110 @@
+directoryList = $this->getMock('\Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
+ $writeFactory = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteFactory', [], [], '', false);
+ $this->writeInterface = $this->getMock(
+ '\Magento\Framework\Filesystem\Directory\WriteInterface',
+ [],
+ [],
+ '',
+ false
+ );
+ $writeFactory->expects($this->once())->method('create')->willReturn($this->writeInterface);
+ $this->model = new GeneratedFiles($this->directoryList, $writeFactory);
+ }
+
+ /**
+ * @param array $getPathMap
+ * @param array $isDirectoryMap
+ * @param bool $delete
+ * @param array $deleteMap
+ * @dataProvider regenerateDataProvider
+ */
+ public function testRegenerate($getPathMap, $isDirectoryMap, $delete, $deleteMap)
+ {
+
+ $this->writeInterface
+ ->expects($this->once())
+ ->method('isExist')
+ ->with(GeneratedFiles::REGENERATE_FLAG)
+ ->willReturn(true);
+ $this->directoryList->expects($this->exactly(2))->method('getPath')->willReturnMap($getPathMap);
+ $this->writeInterface->expects($this->exactly(2))->method('isDirectory')->willReturnMap($isDirectoryMap);
+ $this->writeInterface->expects($this->exactly($delete))->method('delete')->willReturnMap($deleteMap);
+ $this->model->regenerate();
+ }
+
+ /**
+ * @return array
+ */
+ public function regenerateDataProvider()
+ {
+ $pathToGeneration = 'path/to/generation';
+ $pathToDi = 'path/to/di';
+
+ $getPathMap = [[DirectoryList::GENERATION, $pathToGeneration],
+ [DirectoryList::DI, $pathToDi]];
+ $deleteMap = [[BP . '/' . $pathToGeneration, true],
+ [BP . '/' . $pathToDi, true],
+ [BP . GeneratedFiles::REGENERATE_FLAG, true],
+ ];
+
+ return [
+ 'runAll' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true],
+ [BP . '/' . $pathToDi, true]], 3, $deleteMap ],
+ 'noDIfolder' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true],
+ [BP . '/' . $pathToDi, false]], 2, $deleteMap],
+ 'noGenerationfolder' => [$getPathMap, [[BP . '/' . $pathToGeneration, false],
+ [BP . '/' . $pathToDi, true]], 2 ,$deleteMap],
+ 'nofolders' => [ $getPathMap, [[BP . '/' . $pathToGeneration, false],
+ [BP . '/' . $pathToDi, false]], 1, $deleteMap],
+ ];
+ }
+
+ public function testRegenerateWithNoFlag()
+ {
+ $this->writeInterface
+ ->expects($this->once())
+ ->method('isExist')
+ ->with(BP. GeneratedFiles::REGENERATE_FLAG)
+ ->willReturn(false);
+ $this->directoryList->expects($this->never())->method('getPath');
+ $this->writeInterface->expects($this->never())->method('getPath');
+ $this->writeInterface->expects($this->never())->method('delete');
+ $this->model->regenerate();
+ }
+
+ public function testRequestRegeneration()
+ {
+ $this->writeInterface->expects($this->once())->method("touch");
+ $this->model->regenerate();
+ }
+}
diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
index 725094e7cd0f3..710937d66c5fe 100644
--- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
@@ -30,7 +30,7 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand
* @param GeneratedFiles $generatedFiles
* @param ObjectManagerProvider $objectManagerProvider
*/
- public function __construct(GeneratedFiles $generatedFiles,ObjectManagerProvider $objectManagerProvider)
+ public function __construct(GeneratedFiles $generatedFiles, ObjectManagerProvider $objectManagerProvider)
{
$this->generatedFiles = $generatedFiles;
parent::__construct($objectManagerProvider);
@@ -121,7 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$this->cleanup($input, $output);
- $this->generatedFiles->createRequestForRegeneration();
+ $this->generatedFiles->requestRegeneration();
if ($force) {
$output->writeln(
diff --git a/setup/src/Magento/Setup/Controller/StartUpdater.php b/setup/src/Magento/Setup/Controller/StartUpdater.php
index d043d317da7d7..f0e9c84ff4e5d 100644
--- a/setup/src/Magento/Setup/Controller/StartUpdater.php
+++ b/setup/src/Magento/Setup/Controller/StartUpdater.php
@@ -10,6 +10,7 @@
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
use Zend\View\Model\ViewModel;
+use Zend\Json\Json;
/**
* Controller for updater tasks
diff --git a/setup/src/Magento/Setup/Model/PayloadValidator.php b/setup/src/Magento/Setup/Model/PayloadValidator.php
index 796d7d6db874a..9daac58f61211 100644
--- a/setup/src/Magento/Setup/Model/PayloadValidator.php
+++ b/setup/src/Magento/Setup/Model/PayloadValidator.php
@@ -6,15 +6,11 @@
namespace Magento\Setup\Model;
-use Magento\Setup\Controller\StartUpdater;
-
/**
* Validates payloads for updater tasks
*/
class PayloadValidator
{
-
-
/**
* @var \Magento\Framework\Module\FullModuleList
*/
@@ -23,9 +19,7 @@ class PayloadValidator
/**
* @param \Magento\Framework\Module\FullModuleList $moduleList
*/
- public function __construct(
- \Magento\Framework\Module\FullModuleList $moduleList
- ) {
+ public function __construct(\Magento\Framework\Module\FullModuleList $moduleList) {
$this->moduleList = $moduleList;
}
@@ -80,12 +74,17 @@ private function validateUninstallPayload(array $postPayload)
private function validateUpdatePayload(array $postPayload)
{
$errorMessage = '';
- $packages = $postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES];
- foreach ($packages as $package) {
- if ((!isset($package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME]))
- || (!isset($package[UpdaterTaskCreator::KEY_POST_PACKAGE_VERSION]))) {
- $errorMessage .= 'Missing package information' . PHP_EOL;
- break;
+ if (!isset($postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES])) {
+ $errorMessage = 'Missing packages' . PHP_EOL;
+ } else {
+ $packages = $postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES];
+ foreach ($packages as $package) {
+ if ((!isset($package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME]))
+ || (!isset($package[UpdaterTaskCreator::KEY_POST_PACKAGE_VERSION]))
+ ) {
+ $errorMessage .= 'Missing package information' . PHP_EOL;
+ break;
+ }
}
}
return $errorMessage;
@@ -100,12 +99,16 @@ private function validateUpdatePayload(array $postPayload)
private function validateEnableDisablePayload(array $postPayload)
{
$errorMessage = '';
- $packages = $postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES];
- foreach ($packages as $package) {
- if (!$this->moduleList->has($package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME])) {
- $errorMessage .= 'Invalid Magento module name: ' . $package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME]
- . PHP_EOL;
- break;
+ if (!isset($postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES])) {
+ $errorMessage = 'Missing packages' . PHP_EOL;
+ } else {
+ $packages = $postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES];
+ foreach ($packages as $package) {
+ if (!$this->moduleList->has($package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME])) {
+ $errorMessage .= 'Invalid Magento module name: '
+ . $package[UpdaterTaskCreator::KEY_POST_PACKAGE_NAME] . PHP_EOL;
+ break;
+ }
}
}
return $errorMessage;
diff --git a/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php b/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
index eab70cf30d660..3c342d6dbae18 100644
--- a/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
+++ b/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
@@ -7,7 +7,6 @@
namespace Magento\Setup\Model;
-use Magento\Setup\Controller\StartUpdater;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Setup\Model\Cron\JobComponentUninstall;
use Zend\Json\Json;
@@ -114,6 +113,8 @@ public function createUpdaterTasks(array $postPayload)
['enable' => true]
);
+ $cacheStatus = $this->cacheManager->getStatus();
+
$errorMessage .= $this->updater->createUpdaterTask(
[],
\Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE,
@@ -142,7 +143,6 @@ public function createUpdaterTasks(array $postPayload)
);
}
- $cacheStatus = $this->cacheManager->getStatus();
$enabledCaches = [];
foreach ($cacheStatus as $cacheName => $value) {
if ($value) {
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
index 3118f17dfc87f..f05170635f3c5 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
@@ -36,6 +36,11 @@ class ModuleEnableDisableCommandTest extends \PHPUnit_Framework_TestCase
*/
private $fullModuleList;
+ /**
+ * @var \Magento\Framework\Code\GeneratedFiles|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $generatedFiles;
+
protected function setUp()
{
$this->objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
@@ -47,6 +52,8 @@ protected function setUp()
$this->cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false);
$this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false);
$this->fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false);
+ $this->generatedFiles = $this->getMock('\Magento\Framework\Code\GeneratedFiles', [], [], '', false);
+
$objectManager->expects($this->any())
->method('get')
->will($this->returnValueMap([
@@ -57,13 +64,6 @@ protected function setUp()
]));
}
- protected function tearDown()
- {
- if (file_exists(BP . '/var/.regenerate')) {
- unlink(BP . '/var/.regenerate');
- }
- }
-
/**
* @param bool $isEnable
* @param bool $clearStaticContent
@@ -93,9 +93,11 @@ public function testExecute($isEnable, $clearStaticContent, $expectedMessage)
$this->cleanupFiles->expects($clearStaticContent ? $this->once() : $this->never())
->method('clearMaterializedViewFiles');
+ $this->generatedFiles->expects($this->once())->method('requestRegeneration');
+
$commandTester = $isEnable
- ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider))
- : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
+ ? new CommandTester(new ModuleEnableCommand($this->generatedFiles, $this->objectManagerProvider))
+ : new CommandTester(new ModuleDisableCommand($this->generatedFiles, $this->objectManagerProvider));
$input = ['module' => ['Magento_Module1', 'Magento_Module2']];
if ($clearStaticContent) {
$input['--clear-static-content'] = true;
@@ -141,7 +143,10 @@ public function testExecuteEnableInvalidModule()
->method('getModulesToChange')
->with(true, ['invalid'])
->willThrowException(new \LogicException('Unknown module(s): invalid'));
- $commandTester = new CommandTester(new ModuleEnableCommand($this->objectManagerProvider));
+ $commandTester = new CommandTester(new ModuleEnableCommand(
+ $this->generatedFiles,
+ $this->objectManagerProvider)
+ );
$input = ['module' => ['invalid']];
$commandTester->execute($input);
$this->assertEquals('Unknown module(s): invalid' . PHP_EOL, $commandTester->getDisplay());
@@ -153,7 +158,10 @@ public function testExecuteDisableInvalidModule()
->method('getModulesToChange')
->with(false, ['invalid'])
->willThrowException(new \LogicException('Unknown module(s): invalid'));
- $commandTester = new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
+ $commandTester = new CommandTester(new ModuleDisableCommand(
+ $this->generatedFiles,
+ $this->objectManagerProvider)
+ );
$input = ['module' => ['invalid']];
$commandTester->execute($input);
$this->assertEquals('Unknown module(s): invalid' . PHP_EOL, $commandTester->getDisplay());
@@ -185,8 +193,8 @@ public function testExecuteAll($isEnable, $expectedMessage)
->with($isEnable, ['Magento_Module1']);
$commandTester = $isEnable
- ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider))
- : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
+ ? new CommandTester(new ModuleEnableCommand($this->generatedFiles, $this->objectManagerProvider))
+ : new CommandTester(new ModuleDisableCommand($this->generatedFiles, $this->objectManagerProvider));
$input = ['--all' => true];
$commandTester->execute($input);
$this->assertStringMatchesFormat($expectedMessage, $commandTester->getDisplay());
@@ -223,8 +231,8 @@ public function testExecuteWithConstraints($isEnable)
->method('setIsEnabled');
$commandTester = $isEnable
- ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider))
- : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
+ ? new CommandTester(new ModuleEnableCommand($this->generatedFiles, $this->objectManagerProvider))
+ : new CommandTester(new ModuleDisableCommand($this->generatedFiles, $this->objectManagerProvider));
$commandTester->execute(['module' => ['Magento_Module1', 'Magento_Module2']]);
$this->assertStringMatchesFormat(
'Unable to change status of modules%aconstraint1%aconstraint2%a',
@@ -264,8 +272,8 @@ public function testExecuteForce($isEnable, $expectedMessage)
->with($isEnable, ['Magento_Module1']);
$commandTester = $isEnable
- ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider))
- : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
+ ? new CommandTester(new ModuleEnableCommand($this->generatedFiles, $this->objectManagerProvider))
+ : new CommandTester(new ModuleDisableCommand($this->generatedFiles, $this->objectManagerProvider));
$commandTester->execute(['module' => ['Magento_Module1', 'Magento_Module2'], '--force' => true]);
$this->assertStringMatchesFormat(
$expectedMessage . '%amodules might not function properly%a',
@@ -300,8 +308,8 @@ public function testExecuteNoChanges($isEnable)
->method('setIsEnabled');
$commandTester = $isEnable
- ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider))
- : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
+ ? new CommandTester(new ModuleEnableCommand($this->generatedFiles, $this->objectManagerProvider))
+ : new CommandTester(new ModuleDisableCommand($this->generatedFiles, $this->objectManagerProvider));
$commandTester->execute(['module' => ['Magento_Module1', 'Magento_Module2']]);
$this->assertStringMatchesFormat(
'No modules were changed%a',
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
index 9491d518ea230..b487ac9225384 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
@@ -11,26 +11,6 @@
class StartUpdaterTest extends \PHPUnit_Framework_TestCase
{
- /**
- * @var \Magento\Setup\Model\Updater|\PHPUnit_Framework_MockObject_MockObject
- */
- private $updater;
-
- /**
- * @var \Magento\Framework\Module\FullModuleList|\PHPUnit_Framework_MockObject_MockObject
- */
- private $fullModuleList;
-
- /**
- * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
- */
- private $filesystem;
-
- /**
- * @var Navigation|\PHPUnit_Framework_MockObject_MockObject
- */
- private $navigation;
-
/**
* @var StartUpdater|\PHPUnit_Framework_MockObject_MockObject
*/
@@ -50,27 +30,26 @@ class StartUpdaterTest extends \PHPUnit_Framework_TestCase
* @var \Zend\Mvc\MvcEvent|\PHPUnit_Framework_MockObject_MockObject
*/
private $mvcEvent;
-
+
+ /**
+ * @var Magento\Setup\Model\PayloadValidator|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $payloadValidator;
+
+ /**
+ * @var Magento\Setup\Model\UpdaterTaskCreator|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $updaterTaskCreator;
+
public function setUp()
{
- $this->updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false);
- $this->fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false);
- $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
- $this->navigation = $this->getMock('Magento\Setup\Model\Navigation', [], [], '', false);
+ $this->payloadValidator = $this->getMock('Magento\Setup\Model\PayloadValidator', [], [], '', false);
+ $this->updaterTaskCreator = $this->getMock('Magento\Setup\Model\UpdaterTaskCreator', [], [], '', false);
+
$this->controller = new StartUpdater(
- $this->filesystem,
- $this->navigation,
- $this->updater,
- $this->fullModuleList
+ $this->updaterTaskCreator,
+ $this->payloadValidator
);
- $this->navigation->expects($this->any())
- ->method('getMenuItems')
- ->willReturn([
- ['title' => 'A', 'type' => 'update'],
- ['title' => 'B', 'type' => 'upgrade'],
- ['title' => 'C', 'type' => 'enable'],
- ['title' => 'D', 'type' => 'disable'],
- ]);
$this->request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false);
$this->response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false);
$routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false);
@@ -97,125 +76,41 @@ public function testIndexAction()
$this->assertTrue($viewModel->terminate());
}
- public function testUpdateInvalidRequestNoParam()
- {
- $content = '{}';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->filesystem->expects($this->never())->method('getDirectoryWrite');
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
- }
-
- public function testUpdateInvalidRequestNotArray()
- {
- $content = '{"packages":"test","type":"update"}';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->filesystem->expects($this->never())->method('getDirectoryWrite');
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
- }
-
- public function testUpdateInvalidRequestMissingVersion()
- {
- $content = '{"packages":[{"name":"vendor\/package"}],"type":"update"}';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->filesystem->expects($this->never())->method('getDirectoryWrite');
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
- }
-
- public function testUpdateInvalidRequestMissingDataOption()
+ /**
+ * @param string $content
+ * @param int $content
+ * @dataProvider updateInvalidRequestDataProvider
+ */
+ public function testUpdateInvalidRequest($content, $payload)
{
- $content = '{"packages":[{"name":"vendor\/package", "version": "1.0.0"}],"type":"uninstall"}';
$this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->filesystem->expects($this->never())->method('getDirectoryWrite');
+ $this->payloadValidator->expects($this->exactly($payload))->method('validatePayload');
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
}
- public function testUpdateMissingPackageInfo()
+ /**
+ * @return array
+ */
+ public function updateInvalidRequestDataProvider()
{
- $content = '{"packages":"test","type":"update"}';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->filesystem->expects($this->never())->method('getDirectoryWrite');
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
+ return [
+ 'NoParmas' => ['{}', 0],
+ 'NoArray' => ['{"packages":"test","type":"update"}', 0],
+ 'NoVersion' => ['{"packages":[{"name":"vendor\/package"}],"type":"update"}', 1],
+ 'NoDataOption' => ['{"packages":[{"name":"vendor\/package", "version": "1.0.0"}],"type":"uninstall"}', 1],
+ 'NoPackageInfo' => ['{"packages":"test","type":"update"}', 0]
+ ];
}
- public function testUpdateActionSuccessUpdate()
+ public function testUpdateActionSuccess()
{
$content = '{"packages":[{"name":"vendor\/package","version":"1.0"}],"type":"update",'
. '"headerTitle": "Update package 1" }';
$this->request->expects($this->any())->method('getContent')->willReturn($content);
- $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false);
- $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
- $write->expects($this->once())
- ->method('writeFile')
- ->with('.type.json', '{"type":"update","headerTitle":"Update package 1","titles":["A"]}');
- $this->updater->expects($this->at(1))
- ->method('createUpdaterTask')
- ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
- }
-
- public function testUpdateActionSuccessUpgrade()
- {
- $content = '{"packages":[{"name":"vendor\/package","version":"1.0"}],"type":"upgrade",'
- . '"headerTitle": "System Upgrade" }';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false);
- $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
- $write->expects($this->once())
- ->method('writeFile')
- ->with('.type.json', '{"type":"upgrade","headerTitle":"System Upgrade","titles":["B"]}');
- $this->updater->expects($this->at(1))
- ->method('createUpdaterTask')
- ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
- }
-
- public function testUpdateActionSuccessEnable()
- {
- $content = '{"packages":[{"name":"vendor\/package"}],"type":"enable",'
- . '"headerTitle": "Enable Package 1" }';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->fullModuleList->expects($this->once())->method('has')->willReturn(true);
- $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false);
- $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
- $write->expects($this->once())
- ->method('writeFile')
- ->with('.type.json', '{"type":"enable","headerTitle":"Enable Package 1","titles":["C"]}');
- $this->updater->expects($this->at(1))
- ->method('createUpdaterTask')
- ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
- $this->controller->setEvent($this->mvcEvent);
- $this->controller->dispatch($this->request, $this->response);
- $this->controller->updateAction();
- }
-
- public function testUpdateActionSuccessDisable()
- {
- $content = '{"packages":[{"name":"vendor\/package"}],"type":"disable",'
- . '"headerTitle": "Disable Package 1" }';
- $this->request->expects($this->any())->method('getContent')->willReturn($content);
- $this->fullModuleList->expects($this->once())->method('has')->willReturn(true);
- $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false);
- $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
- $write->expects($this->once())
- ->method('writeFile')
- ->with('.type.json', '{"type":"disable","headerTitle":"Disable Package 1","titles":["D"]}');
- $this->updater->expects($this->at(1))
- ->method('createUpdaterTask')
- ->with([], \Magento\Setup\Model\Cron\JobFactory::JOB_DISABLE_CACHE, []);
+ $this->payloadValidator->expects($this->once())->method('validatePayload')->willReturn('');
+ $this->updaterTaskCreator->expects($this->once())->method('createUpdaterTasks')->willReturn('');
$this->controller->setEvent($this->mvcEvent);
$this->controller->dispatch($this->request, $this->response);
$this->controller->updateAction();
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php
new file mode 100644
index 0000000000000..6962d55f329ee
--- /dev/null
+++ b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php
@@ -0,0 +1,91 @@
+fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false);
+ $this->model = new PayloadValidator($this->fullModuleList);
+ }
+
+ /**
+ * @param string $type
+ * @param int $has
+ * @param bool $moduleExists
+ * @dataProvider validatePayLoadDataProvider
+ */
+ public function testValidatePayLoad($type, $has, $moduleExists)
+ {
+ $this->fullModuleList->expects($this->exactly($has))->method('has')->willReturn($moduleExists);
+ $this->assertEquals('', $this->model->validatePayload($type));
+ }
+
+ public function validatePayLoadDataProvider()
+ {
+ return [
+ [['type' => 'uninstall', 'dataOption' => true], 0, false],
+ [['type' => 'update', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1']]], 0, false],
+ [['type' => 'enable', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1']]], 1, true],
+ [['type' => 'disable', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1']]], 1, true],
+ ];
+ }
+
+ /**
+ * @param string $type
+ * @param int $has
+ * @param bool $moduleExists
+ * @param string $errorMessage
+ * @dataProvider validatePayLoadNegativeCasesDataProvider
+ */
+ public function testValidatePayLoadNegativeCases($type, $has, $moduleExists, $errorMessage)
+ {
+ $this->fullModuleList->expects($this->exactly($has))->method('has')->willReturn($moduleExists);
+ $this->assertStringStartsWith($errorMessage, $this->model->validatePayload($type));
+ }
+
+ public function validatePayLoadNegativeCasesDataProvider()
+ {
+ return [
+ [['type' => 'uninstall'], 0, false, 'Missing dataOption'],
+ [['type' => 'update'], 0, false, 'Missing packages'],
+ [['type' => 'update',
+ 'packages' => [['name' => 'vendor\/package']]],
+ 0,
+ false,
+ 'Missing package information'
+ ],
+ [['type' => 'enable'], 0, false, 'Missing packages'],
+ [['type' => 'enable',
+ 'packages' => [['name' => 'vendor\/package']]],
+ 1,
+ false,
+ 'Invalid Magento module name'
+ ],
+ [['type' => 'disable',
+ 'packages' => [['name' => 'vendor\/package']]],
+ 1,
+ false,
+ 'Invalid Magento module name'
+ ]
+ ];
+ }
+}
\ No newline at end of file
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php
new file mode 100644
index 0000000000000..02599a9dcf211
--- /dev/null
+++ b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php
@@ -0,0 +1,86 @@
+updater = $this->getMock('Magento\Setup\Model\Updater', [], [], '', false);
+ $this->cacheManager = $this->getMock('\Magento\Framework\App\Cache\Manager', [], [], '', false);
+ $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
+ $this->navigation = $this->getMock('Magento\Setup\Model\Navigation', [], [], '', false);
+ $this->model = new UpdaterTaskCreator(
+ $this->filesystem,
+ $this->navigation,
+ $this->updater,
+ $this->cacheManager
+ );
+ $this->navigation->expects($this->any())
+ ->method('getMenuItems')
+ ->willReturn([
+ ['title' => 'A', 'type' => 'update'],
+ ['title' => 'B', 'type' => 'upgrade'],
+ ['title' => 'C', 'type' => 'enable'],
+ ['title' => 'D', 'type' => 'disable'],
+ ]);
+ }
+
+ /**
+ * @dataProvider createUpdaterTasksDataProvider
+ */
+ public function testCreateUpdaterTasks($payload, $one, $two)
+ {
+ $write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false);
+ $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
+ $write->expects($this->once())
+ ->method('writeFile');
+ //->with('.type.json', '{"type":"enable","headerTitle":"Enable Package 1","titles":["C"]}');
+ $this->cacheManager->expects($this->once())->method('getStatus')->willReturn([
+ 'cache1' => 1, 'cache2' => 0, 'cache3' => 1
+ ]);
+ $this->model->createUpdaterTasks($payload);
+ }
+
+ /**
+ * @return array
+ */
+ public function createUpdaterTasksDataProvider()
+ {
+ return [
+ [['type' => 'uninstall', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1']], 'headerTitle'=>'Uninstall Package1', 'dataOption' => true], 0, false],
+ [['type' => 'update', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]], 'headerTitle'=>'Uninstall Package1'], 0, false],
+ [['type' => 'enable', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]], 'headerTitle'=>'Uninstall Package1'], 1, true],
+ [['type' => 'disable', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]], 'headerTitle'=>'Uninstall Package1'], 1, true],
+ ];
+ }
+
+}
From ce78114bec65cf8ff92c409a0b4eedfa2ff625f0 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 12 Apr 2016 08:15:04 -0500
Subject: [PATCH 24/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR comments
- Fixing static tests
---
.../Framework/App/ObjectManagerFactory.php | 2 +-
.../Magento/Framework/Code/GeneratedFiles.php | 23 ++++++++-------
.../Code/Test/Unit/GeneratedFilesTest.php | 4 +--
.../Magento/Setup/Model/PayloadValidator.php | 5 ++--
.../Setup/Model/UpdaterTaskCreator.php | 2 +-
.../ModuleEnableDisableCommandTest.php | 8 ++---
.../Test/Unit/Controller/StartUpdaterTest.php | 2 +-
.../Test/Unit/Model/PayloadValidatorTest.php | 3 +-
.../Unit/Model/UpdaterTaskCreatorTest.php | 29 ++++++++++++-------
9 files changed, 45 insertions(+), 33 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
index 4319bf9f9861b..1b84ed9bb008b 100644
--- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
+++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php
@@ -109,7 +109,7 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool
*/
public function create(array $arguments)
{
- $writeFactory = new \Magento\Framework\Filesystem\Directory\WriteFactory($this->driverPool);
+ $writeFactory = new \Magento\Framework\Filesystem\Directory\WriteFactory($this->driverPool);
$generatedFiles = new GeneratedFiles($this->directoryList, $writeFactory);
$generatedFiles->regenerate();
diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
index ce2cd3ca49d97..d0cce5fed540a 100644
--- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
@@ -16,17 +16,17 @@ class GeneratedFiles
{
/**
* Separator literal to assemble timer identifier from timer names
- */
+ */
const REGENERATE_FLAG = '/var/.regenerate';
/**
* @var DirectoryList
- */
+ */
private $directoryList;
/**
* @var WriteInterface
- */
+ */
private $write;
/**
@@ -34,8 +34,9 @@ class GeneratedFiles
*
* @param DirectoryList $directoryList
* @param WriteFactory $writeFactory
- */
- public function __construct(DirectoryList $directoryList, WriteFactory $writeFactory) {
+ */
+ public function __construct(DirectoryList $directoryList, WriteFactory $writeFactory)
+ {
$this->directoryList = $directoryList;
$this->write = $writeFactory->create(BP);
}
@@ -44,8 +45,8 @@ public function __construct(DirectoryList $directoryList, WriteFactory $writeFac
* Clean generated code and DI configuration
*
* @return void
- */
- public function regenerate()
+ */
+ public function regenerate()
{
if ($this->write->isExist(self::REGENERATE_FLAG)) {
$generationPath = BP . '/' . $this->directoryList->getPath(DirectoryList::GENERATION);
@@ -53,7 +54,7 @@ public function regenerate()
if ($this->write->isDirectory($generationPath)) {
$this->write->delete($generationPath);
- }
+ }
if ($this->write->isDirectory($diPath)) {
$this->write->delete($diPath);
}
@@ -63,9 +64,11 @@ public function regenerate()
/**
* Create flag for regeneration of code and di
- */
+ *
+ * @return void
+ */
public function requestRegeneration()
{
- $this->write->touch(BP . '/var/.regenerate');
+ $this->write->touch(self::REGENERATE_FLAG);
}
}
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
index 44845354687b7..1abfc000449a8 100644
--- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
@@ -94,7 +94,7 @@ public function testRegenerateWithNoFlag()
$this->writeInterface
->expects($this->once())
->method('isExist')
- ->with(BP. GeneratedFiles::REGENERATE_FLAG)
+ ->with(GeneratedFiles::REGENERATE_FLAG)
->willReturn(false);
$this->directoryList->expects($this->never())->method('getPath');
$this->writeInterface->expects($this->never())->method('getPath');
@@ -105,6 +105,6 @@ public function testRegenerateWithNoFlag()
public function testRequestRegeneration()
{
$this->writeInterface->expects($this->once())->method("touch");
- $this->model->regenerate();
+ $this->model->requestRegeneration();
}
}
diff --git a/setup/src/Magento/Setup/Model/PayloadValidator.php b/setup/src/Magento/Setup/Model/PayloadValidator.php
index 9daac58f61211..b024b028cb81f 100644
--- a/setup/src/Magento/Setup/Model/PayloadValidator.php
+++ b/setup/src/Magento/Setup/Model/PayloadValidator.php
@@ -19,7 +19,8 @@ class PayloadValidator
/**
* @param \Magento\Framework\Module\FullModuleList $moduleList
*/
- public function __construct(\Magento\Framework\Module\FullModuleList $moduleList) {
+ public function __construct(\Magento\Framework\Module\FullModuleList $moduleList)
+ {
$this->moduleList = $moduleList;
}
@@ -113,4 +114,4 @@ private function validateEnableDisablePayload(array $postPayload)
}
return $errorMessage;
}
-}
\ No newline at end of file
+}
diff --git a/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php b/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
index 3c342d6dbae18..33debb4bb1c9a 100644
--- a/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
+++ b/setup/src/Magento/Setup/Model/UpdaterTaskCreator.php
@@ -194,4 +194,4 @@ private function getCronTaskConfigInfo($jobType, $postPayload, &$additionalOptio
break;
}
}
-}
\ No newline at end of file
+}
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
index f05170635f3c5..b6e3dd6130f2e 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
@@ -145,8 +145,8 @@ public function testExecuteEnableInvalidModule()
->willThrowException(new \LogicException('Unknown module(s): invalid'));
$commandTester = new CommandTester(new ModuleEnableCommand(
$this->generatedFiles,
- $this->objectManagerProvider)
- );
+ $this->objectManagerProvider
+ ));
$input = ['module' => ['invalid']];
$commandTester->execute($input);
$this->assertEquals('Unknown module(s): invalid' . PHP_EOL, $commandTester->getDisplay());
@@ -160,8 +160,8 @@ public function testExecuteDisableInvalidModule()
->willThrowException(new \LogicException('Unknown module(s): invalid'));
$commandTester = new CommandTester(new ModuleDisableCommand(
$this->generatedFiles,
- $this->objectManagerProvider)
- );
+ $this->objectManagerProvider
+ ));
$input = ['module' => ['invalid']];
$commandTester->execute($input);
$this->assertEquals('Unknown module(s): invalid' . PHP_EOL, $commandTester->getDisplay());
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
index b487ac9225384..ffad28a494fea 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/StartUpdaterTest.php
@@ -78,7 +78,7 @@ public function testIndexAction()
/**
* @param string $content
- * @param int $content
+ * @param int $payload
* @dataProvider updateInvalidRequestDataProvider
*/
public function testUpdateInvalidRequest($content, $payload)
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php
index 6962d55f329ee..cd749cc66a3e9 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/PayloadValidatorTest.php
@@ -20,7 +20,6 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
*/
private $model;
-
public function setUp()
{
$this->fullModuleList = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false);
@@ -88,4 +87,4 @@ public function validatePayLoadNegativeCasesDataProvider()
]
];
}
-}
\ No newline at end of file
+}
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php
index 02599a9dcf211..ac3f67676aef1 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/UpdaterTaskCreatorTest.php
@@ -16,7 +16,6 @@ class UpdaterTaskCreatorTest extends \PHPUnit_Framework_TestCase
*/
private $updater;
-
/**
* @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
*/
@@ -55,15 +54,14 @@ public function setUp()
}
/**
+ * @param array $payload
* @dataProvider createUpdaterTasksDataProvider
*/
- public function testCreateUpdaterTasks($payload, $one, $two)
+ public function testCreateUpdaterTasks($payload)
{
$write = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface', [], '', false);
$this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($write);
- $write->expects($this->once())
- ->method('writeFile');
- //->with('.type.json', '{"type":"enable","headerTitle":"Enable Package 1","titles":["C"]}');
+ $write->expects($this->once())->method('writeFile');
$this->cacheManager->expects($this->once())->method('getStatus')->willReturn([
'cache1' => 1, 'cache2' => 0, 'cache3' => 1
]);
@@ -76,11 +74,22 @@ public function testCreateUpdaterTasks($payload, $one, $two)
public function createUpdaterTasksDataProvider()
{
return [
- [['type' => 'uninstall', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1']], 'headerTitle'=>'Uninstall Package1', 'dataOption' => true], 0, false],
- [['type' => 'update', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]], 'headerTitle'=>'Uninstall Package1'], 0, false],
- [['type' => 'enable', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]], 'headerTitle'=>'Uninstall Package1'], 1, true],
- [['type' => 'disable', 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]], 'headerTitle'=>'Uninstall Package1'], 1, true],
+ [['type' => 'uninstall',
+ 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1']],
+ 'headerTitle'=>'Uninstall Package1', 'dataOption' => true
+ ], 0, false],
+ [['type' => 'update',
+ 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]],
+ 'headerTitle'=>'Uninstall Package1'
+ ], 0, false],
+ [['type' => 'enable',
+ 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]],
+ 'headerTitle'=>'Uninstall Package1'
+ ], 1, true],
+ [['type' => 'disable',
+ 'packages' => [['name' => 'vendor\/package', 'version' => '1.0.1',]],
+ 'headerTitle'=>'Uninstall Package1'
+ ], 1, true],
];
}
-
}
From 6174d2b1d4c8e70f957c01735037022b18ad92a8 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 12 Apr 2016 09:14:07 -0500
Subject: [PATCH 25/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Fixing static tests
---
lib/internal/Magento/Framework/Code/GeneratedFiles.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
index d0cce5fed540a..2c480d5b28fbd 100644
--- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
@@ -16,17 +16,17 @@ class GeneratedFiles
{
/**
* Separator literal to assemble timer identifier from timer names
- */
+ */
const REGENERATE_FLAG = '/var/.regenerate';
/**
* @var DirectoryList
- */
+ */
private $directoryList;
/**
* @var WriteInterface
- */
+ */
private $write;
/**
@@ -34,7 +34,7 @@ class GeneratedFiles
*
* @param DirectoryList $directoryList
* @param WriteFactory $writeFactory
- */
+ */
public function __construct(DirectoryList $directoryList, WriteFactory $writeFactory)
{
$this->directoryList = $directoryList;
@@ -45,7 +45,7 @@ public function __construct(DirectoryList $directoryList, WriteFactory $writeFac
* Clean generated code and DI configuration
*
* @return void
- */
+ */
public function regenerate()
{
if ($this->write->isExist(self::REGENERATE_FLAG)) {
From bba17d5cf0906ef410b46088207b7751f1e3c3bc Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 12 Apr 2016 09:41:22 -0500
Subject: [PATCH 26/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Fixing static tests
---
lib/internal/Magento/Framework/Code/GeneratedFiles.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
index 2c480d5b28fbd..a974f612401ce 100644
--- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
@@ -66,7 +66,7 @@ public function regenerate()
* Create flag for regeneration of code and di
*
* @return void
- */
+ */
public function requestRegeneration()
{
$this->write->touch(self::REGENERATE_FLAG);
From 79224ea8949f82184970fab67966f8fdd3daf20d Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 12 Apr 2016 14:41:32 -0500
Subject: [PATCH 27/52] MAGETWO-50846: [Github] Error in Tests unit #3715
- removing @covers annotation
---
.../Test/Unit/Controller/MarketplaceTest.php | 21 -------------------
1 file changed, 21 deletions(-)
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php
index cbfc35e9286c6..a7ad065b595a1 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php
@@ -35,9 +35,6 @@ public function setUp()
$this->controller = new Marketplace($this->composerInformation, $this->marketplaceManager);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::saveAuthJsonAction
- */
public function testSaveAuthJsonAction()
{
$this->marketplaceManager
@@ -55,9 +52,6 @@ public function testSaveAuthJsonAction()
$this->assertTrue($variables['success']);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::saveAuthJsonAction
- */
public function testSaveAuthJsonActionWithError()
{
$this->marketplaceManager
@@ -75,9 +69,6 @@ public function testSaveAuthJsonActionWithError()
$this->assertFalse($variables['success']);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::checkAuthAction
- */
public function testCheckAuthAction()
{
$this->marketplaceManager
@@ -95,9 +86,6 @@ public function testCheckAuthAction()
$this->assertTrue($variables['success']);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::checkAuthAction
- */
public function testCheckAuthActionWithError()
{
$this->marketplaceManager
@@ -112,9 +100,6 @@ public function testCheckAuthActionWithError()
$this->assertFalse($variables['success']);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::removeCredentialsAction
- */
public function testRemoveCredentialsAction()
{
$this->marketplaceManager
@@ -129,9 +114,6 @@ public function testRemoveCredentialsAction()
$this->assertTrue($variables['success']);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::removeCredentialsAction
- */
public function testRemoveCredentialsWithError()
{
$this->marketplaceManager
@@ -146,9 +128,6 @@ public function testRemoveCredentialsWithError()
$this->assertFalse($variables['success']);
}
- /**
- * @covers \Magento\Setup\Controller\Marketplace::popupAuthAction
- */
public function testPopupAuthAction()
{
$viewModel = $this->controller->popupAuthAction();
From bd27434723310cc2c613c96004d43bfd53180776 Mon Sep 17 00:00:00 2001
From: Olga Kopylova
Date: Wed, 13 Apr 2016 16:34:00 -0500
Subject: [PATCH 28/52] MAGETWO-51881: Widget of type Catalog Events Carousel
is not displayed in page
- added verbosity to exception
---
.../Magento/Framework/Stdlib/DateTime/Filter/DateTime.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
index 8838d915619f5..445f4c899f10d 100644
--- a/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
+++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
@@ -37,15 +37,15 @@ public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface
*
* @param string $value
* @return string
- * @throws LocalizedException
+ * @throws \Exception
*/
public function filter($value)
{
try {
- $value = new \DateTime($value);
- return $value->format('Y-m-d H:i:s');
+ $dateTime = new \DateTime($value);
+ return $dateTime->format('Y-m-d H:i:s');
} catch (\Exception $e) {
- throw new \Exception('Invalid input datetime format');
+ throw new \Exception((string)__("Invalid input datetime format of value '%1'", $value));
}
}
}
From a455e37c7a65affbf3258e708b70f0468ce794e2 Mon Sep 17 00:00:00 2001
From: Olga Kopylova
Date: Wed, 13 Apr 2016 19:42:32 -0500
Subject: [PATCH 29/52] MAGETWO-51881: Widget of type Catalog Events Carousel
is not displayed in page
- added more verbosity to exception
---
.../Magento/Framework/Stdlib/DateTime/Filter/DateTime.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
index 445f4c899f10d..f2181fa3f11e7 100644
--- a/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
+++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
@@ -45,7 +45,7 @@ public function filter($value)
$dateTime = new \DateTime($value);
return $dateTime->format('Y-m-d H:i:s');
} catch (\Exception $e) {
- throw new \Exception((string)__("Invalid input datetime format of value '%1'", $value));
+ throw new \Exception((string)__("Invalid input datetime format of value '%1': '%2'", $value, $e->getMessage()));
}
}
}
From 5e1995699dba6e31324bfc60676147cb9c1778af Mon Sep 17 00:00:00 2001
From: Olga Kopylova
Date: Wed, 13 Apr 2016 19:56:10 -0500
Subject: [PATCH 30/52] MAGETWO-51881: Widget of type Catalog Events Carousel
is not displayed in page
- added details to exception caused by incorrect date format
---
.../tests/app/Magento/Backend/Test/Fixture/Source/Date.php | 2 +-
.../Magento/Framework/Stdlib/DateTime/Filter/DateTime.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Fixture/Source/Date.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Fixture/Source/Date.php
index a3e51d4e0ee44..08e215a63c3db 100644
--- a/dev/tests/functional/tests/app/Magento/Backend/Test/Fixture/Source/Date.php
+++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Fixture/Source/Date.php
@@ -12,7 +12,7 @@
* Class Date.
*
* Data keys:
- * - pattern (Format a local time/date with delta, e.g. 'm-d-Y -3 days' = current day - 3 days)
+ * - pattern (Format a local time/date with delta, e.g. 'm/d/Y -3 days' = current day - 3 days)
*/
class Date extends DataSource
{
diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
index f2181fa3f11e7..8e3b55c2cb45f 100644
--- a/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
+++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Filter/DateTime.php
@@ -45,7 +45,7 @@ public function filter($value)
$dateTime = new \DateTime($value);
return $dateTime->format('Y-m-d H:i:s');
} catch (\Exception $e) {
- throw new \Exception((string)__("Invalid input datetime format of value '%1': '%2'", $value, $e->getMessage()));
+ throw new \Exception("Invalid input datetime format of value '$value'", $e->getCode(), $e);
}
}
}
From 395dc254515b385cbd34d285317e2754071429eb Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Thu, 14 Apr 2016 14:09:29 -0500
Subject: [PATCH 31/52] MAGETWO-50846: [Github] Error in Tests unit #3715
- fixing test to check @covers annotation
- fixing wrong @covers annotations
---
.../Test/Unit/Observer/AfterImportDataObserverTest.php | 1 -
.../Initialization/Helper/Plugin/ConfigurableTest.php | 9 ---------
.../Magento/Marketplace/Test/Unit/Helper/CacheTest.php | 4 ++--
.../testsuite/Magento/Test/Integrity/ClassesTest.php | 8 +++++++-
.../Framework/Setup/Test/Unit/FilePermissionsTest.php | 4 ++--
.../Framework/Setup/Test/Unit/SampleData/StateTest.php | 2 +-
.../Magento/Setup/Test/Unit/Controller/SessionTest.php | 2 +-
7 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php
index 5fafdc2bc77db..35364884b157a 100644
--- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php
+++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php
@@ -299,7 +299,6 @@ protected function setUp()
* Test for afterImportData()
* Covers afterImportData() + protected methods used inside
*
- * @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::afterImportData
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::_populateForUrlGeneration
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::isGlobalScope
* @covers \Magento\CatalogUrlRewrite\Observer\AfterImportDataObserver::populateGlobalProduct
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php
index f8b42171dd674..b078b96458b99 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php
@@ -203,9 +203,6 @@ public function testAfterInitializeWithAttributesAndVariations()
$this->plugin->afterInitialize($this->subject, $this->product);
}
- /**
- * @covers Configurable::afterInitialize
- */
public function testAfterInitializeWithAttributesAndWithoutVariations()
{
$attributes = [
@@ -268,9 +265,6 @@ public function testAfterInitializeWithAttributesAndWithoutVariations()
$this->plugin->afterInitialize($this->subject, $this->product);
}
- /**
- * @covers Configurable::afterInitialize
- */
public function testAfterInitializeIfAttributesEmpty()
{
$this->product->expects(static::once())
@@ -291,9 +285,6 @@ public function testAfterInitializeIfAttributesEmpty()
$this->plugin->afterInitialize($this->subject, $this->product);
}
- /**
- * @covers Configurable::afterInitialize
- */
public function testAfterInitializeForNotConfigurableProduct()
{
$this->product->expects(static::once())
diff --git a/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php b/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php
index fa9a5eb60268b..329a060f88c48 100644
--- a/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php
+++ b/app/code/Magento/Marketplace/Test/Unit/Helper/CacheTest.php
@@ -19,7 +19,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Marketplace\Helper::loadPartnersFromCache
+ * @covers \Magento\Marketplace\Helper\Cache::loadPartnersFromCache
*/
public function testLoadPartnersFromCache()
{
@@ -36,7 +36,7 @@ public function testLoadPartnersFromCache()
}
/**
- * @covers \Magento\Marketplace\Helper::savePartnersToCache
+ * @covers \Magento\Marketplace\Helper\Cache::savePartnersToCache
*/
public function testSavePartnersToCache()
{
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php
index efffb09e3f23f..6fcb714335636 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php
@@ -598,7 +598,13 @@ public function testCoversAnnotation()
{
$files = Files::init();
$errors = [];
- foreach ($files->getFiles([BP . '/dev/tests/{integration,unit}'], '*') as $file) {
+ $filesToTest = $files->getPhpFiles(Files::INCLUDE_TESTS);
+
+ if(($key = array_search(__FILE__, $filesToTest)) !== false) {
+ unset($filesToTest[$key]);
+ }
+
+ foreach ($filesToTest as $file) {
$code = file_get_contents($file);
if (preg_match('/@covers(DefaultClass)?\s+([\w\\\\]+)(::([\w\\\\]+))?/', $code, $matches)) {
if ($this->isNonexistentEntityCovered($matches)) {
diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php
index cff6323802083..56ada8571104b 100644
--- a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php
+++ b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php
@@ -133,8 +133,8 @@ public function getApplicationCurrentNonWritableDirectoriesDataProvider()
}
/**
- * @covers \Magento\Framework\FilePermissions::getMissingWritableDirectoriesForInstallation
- * @covers \Magento\Framework\FilePermissions::getMissingWritablePathsForInstallation
+ * @covers \Magento\Framework\Setup\FilePermissions::getMissingWritableDirectoriesForInstallation
+ * @covers \Magento\Framework\Setup\FilePermissions::getMissingWritablePathsForInstallation
*/
public function testGetMissingWritableDirectoriesAndPathsForInstallation()
{
diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php
index 9043cf86d0772..75085bac98e6e 100644
--- a/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php
+++ b/lib/internal/Magento/Framework/Setup/Test/Unit/SampleData/StateTest.php
@@ -61,7 +61,7 @@ public function testClearState()
}
/**
- * @covers setError()
+ * @covers \Magento\Framework\Setup\SampleData\State::setError
*/
public function testHasError()
{
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php
index bb826dda5e123..43050cfecb2be 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/SessionTest.php
@@ -35,7 +35,7 @@ public function setUp()
}
/**
- * @covers \Magento\Setup\Controller\Session::testUnloginAction
+ * @covers \Magento\Setup\Controller\Session::unloginAction
*/
public function testUnloginAction()
{
From 28d65f0327c6662d37bceb5ff5caba4cefbf9757 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Thu, 14 Apr 2016 14:31:44 -0500
Subject: [PATCH 32/52] MAGETWO-50846: [Github] Error in Tests unit #3715
- static fix
---
.../Initialization/Helper/Plugin/ConfigurableTest.php | 10 +++++-----
.../testsuite/Magento/Test/Integrity/ClassesTest.php | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php
index b078b96458b99..35afe5fd261a6 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/ConfigurableTest.php
@@ -21,27 +21,27 @@
class ConfigurableTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var VariationHandler|MockObject
+ * @var Magento\ConfigurableProduct\Model\Product\VariationHandler|MockObject
*/
private $variationHandler;
/**
- * @var Http|MockObject
+ * @var Magento\Framework\App\Request\Http|MockObject
*/
private $request;
/**
- * @var Factory|MockObject
+ * @var Magento\ConfigurableProduct\Helper\Product\Options\Factory|MockObject
*/
private $optionFactory;
/**
- * @var Product|MockObject
+ * @var Magento\Catalog\Model\Product|MockObject
*/
private $product;
/**
- * @var Helper|MockObject
+ * @var Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper|MockObject
*/
private $subject;
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php
index 6fcb714335636..f592eb9ad7bd2 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php
@@ -600,7 +600,7 @@ public function testCoversAnnotation()
$errors = [];
$filesToTest = $files->getPhpFiles(Files::INCLUDE_TESTS);
- if(($key = array_search(__FILE__, $filesToTest)) !== false) {
+ if (($key = array_search(__FILE__, $filesToTest)) !== false) {
unset($filesToTest[$key]);
}
From 2a39b9c219554a585401848fd424c27c85885b78 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 18 Apr 2016 17:46:48 -0500
Subject: [PATCH 33/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Fixing path
---
lib/internal/Magento/Framework/Code/GeneratedFiles.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
index a974f612401ce..a550a740bcfd7 100644
--- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php
+++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php
@@ -49,8 +49,8 @@ public function __construct(DirectoryList $directoryList, WriteFactory $writeFac
public function regenerate()
{
if ($this->write->isExist(self::REGENERATE_FLAG)) {
- $generationPath = BP . '/' . $this->directoryList->getPath(DirectoryList::GENERATION);
- $diPath = BP . '/' . $this->directoryList->getPath(DirectoryList::DI);
+ $generationPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::GENERATION));
+ $diPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::DI));
if ($this->write->isDirectory($generationPath)) {
$this->write->delete($generationPath);
@@ -58,7 +58,7 @@ public function regenerate()
if ($this->write->isDirectory($diPath)) {
$this->write->delete($diPath);
}
- $this->write->delete(BP . self::REGENERATE_FLAG);
+ $this->write->delete(self::REGENERATE_FLAG);
}
}
From e6a3b1d6ac988b9d7cfbad6a9573bf92e14ae543 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 18 Apr 2016 18:11:31 -0500
Subject: [PATCH 34/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- Fixing test
---
.../Code/Test/Unit/GeneratedFilesTest.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
index 1abfc000449a8..d036f8ccd67cc 100644
--- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
+++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php
@@ -44,11 +44,10 @@ protected function setUp()
/**
* @param array $getPathMap
* @param array $isDirectoryMap
- * @param bool $delete
* @param array $deleteMap
* @dataProvider regenerateDataProvider
*/
- public function testRegenerate($getPathMap, $isDirectoryMap, $delete, $deleteMap)
+ public function testRegenerate($getPathMap, $isDirectoryMap, $deleteMap)
{
$this->writeInterface
@@ -57,8 +56,9 @@ public function testRegenerate($getPathMap, $isDirectoryMap, $delete, $deleteMap
->with(GeneratedFiles::REGENERATE_FLAG)
->willReturn(true);
$this->directoryList->expects($this->exactly(2))->method('getPath')->willReturnMap($getPathMap);
+ $this->writeInterface->expects($this->exactly(2))->method('getRelativePath')->willReturnMap($getPathMap);
$this->writeInterface->expects($this->exactly(2))->method('isDirectory')->willReturnMap($isDirectoryMap);
- $this->writeInterface->expects($this->exactly($delete))->method('delete')->willReturnMap($deleteMap);
+ $this->writeInterface->expects($this->exactly(1))->method('delete')->willReturnMap($deleteMap);
$this->model->regenerate();
}
@@ -79,13 +79,13 @@ public function regenerateDataProvider()
return [
'runAll' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true],
- [BP . '/' . $pathToDi, true]], 3, $deleteMap ],
+ [BP . '/' . $pathToDi, true]], $deleteMap ],
'noDIfolder' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true],
- [BP . '/' . $pathToDi, false]], 2, $deleteMap],
+ [BP . '/' . $pathToDi, false]], $deleteMap],
'noGenerationfolder' => [$getPathMap, [[BP . '/' . $pathToGeneration, false],
- [BP . '/' . $pathToDi, true]], 2 ,$deleteMap],
+ [BP . '/' . $pathToDi, true]], $deleteMap],
'nofolders' => [ $getPathMap, [[BP . '/' . $pathToGeneration, false],
- [BP . '/' . $pathToDi, false]], 1, $deleteMap],
+ [BP . '/' . $pathToDi, false]], $deleteMap],
];
}
From 6bdbafeeabf5236f18ee7a6268f9698175b7cafc Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Wed, 20 Apr 2016 09:28:31 -0500
Subject: [PATCH 35/52] MAGETWO-51580: Misleading error messages during
installation - initial commit for better error messaging during readiness
check
---
.../Magento/Setup/Controller/Environment.php | 20 +++++++++++---
.../setup/readiness-check/progress.phtml | 26 ++++++++++++++-----
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php
index f01130a712210..8423550883e9a 100644
--- a/setup/src/Magento/Setup/Controller/Environment.php
+++ b/setup/src/Magento/Setup/Controller/Environment.php
@@ -148,14 +148,28 @@ private function getPhpChecksInfo($type)
public function filePermissionsAction()
{
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
- if ($this->permissions->getMissingWritablePathsForInstallation()) {
+ $missingWritePermissionPaths = $this->permissions->getMissingWritablePathsForInstallation();
+ $requiredPaths = $this->permissions->getInstallationWritableDirectories();
+ if ($missingWritePermissionPaths) {
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
+ $requiredPaths = array_flip($requiredPaths);
+
+ foreach (array_keys($requiredPaths) as $requiredPath) {
+ $missingPaths = [];
+ foreach ($missingWritePermissionPaths as $missingWritePermissionPath) {
+ if (strpos($missingWritePermissionPath, $requiredPath) === 0) {
+ array_push($missingPaths, $missingWritePermissionPath);
+ }
+ }
+ if (!empty($missingPaths)) {
+ $requiredPaths[$requiredPath] = $missingPaths;
+ }
+ }
}
-
$data = [
'responseType' => $responseType,
'data' => [
- 'required' => $this->permissions->getInstallationWritableDirectories(),
+ 'required' => $requiredPaths,
'current' => $this->permissions->getInstallationCurrentWritableDirectories(),
],
];
diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml
index bafb43f8ce5be..eda2c311917c0 100755
--- a/setup/view/magento/setup/readiness-check/progress.phtml
+++ b/setup/view/magento/setup/readiness-check/progress.phtml
@@ -443,25 +443,39 @@
Hide detail
-
+
The best way to resolve this is to allow write permissions for the following Magento
directories and their sub-directories. The exact fix depends on your server, your host,
and other system variables.
Our File Permission Help can get you started.
-
+
If you need more help, please call your hosting provider.
-
-
+
-
- "{{name}}" writable directory permission.
+ "{{name}}"
+
+ - Writable.
+
+
+ - Not writable, change the permissions.
+
+ Show details
+ Hide details
+
+
+
From 5ca6bfd8d4b6c28808d9f297b266f5602745b0a2 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Wed, 20 Apr 2016 13:28:23 -0500
Subject: [PATCH 36/52] MAGETWO-51580: Misleading error messages during
installation
- fixes for paths.
---
.../Framework/Setup/FilePermissions.php | 2 +-
.../Magento/Setup/Controller/Environment.php | 10 ++++++----
.../setup/readiness-check/progress.phtml | 18 +++++++-----------
3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php
index e70e583c27114..4f9d3c79505c0 100644
--- a/lib/internal/Magento/Framework/Setup/FilePermissions.php
+++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php
@@ -161,7 +161,7 @@ private function checkRecursiveDirectories($directory)
try {
foreach ($directoryIterator as $subDirectory) {
if (!$subDirectory->isWritable() && !$subDirectory->isLink()) {
- $this->nonWritablePathsInDirectories[$directory][] = $subDirectory;
+ $this->nonWritablePathsInDirectories[$directory][] = $subDirectory->getPathname();
$foundNonWritable = true;
}
}
diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php
index 8423550883e9a..02eb7a092e824 100644
--- a/setup/src/Magento/Setup/Controller/Environment.php
+++ b/setup/src/Magento/Setup/Controller/Environment.php
@@ -152,17 +152,19 @@ public function filePermissionsAction()
$requiredPaths = $this->permissions->getInstallationWritableDirectories();
if ($missingWritePermissionPaths) {
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
- $requiredPaths = array_flip($requiredPaths);
- foreach (array_keys($requiredPaths) as $requiredPath) {
+ foreach ($requiredPaths as $index => $requiredPath) {
$missingPaths = [];
foreach ($missingWritePermissionPaths as $missingWritePermissionPath) {
if (strpos($missingWritePermissionPath, $requiredPath) === 0) {
- array_push($missingPaths, $missingWritePermissionPath);
+ $missingPaths[] = $missingWritePermissionPath;
}
}
+ unset($requiredPaths[$index]);
if (!empty($missingPaths)) {
- $requiredPaths[$requiredPath] = $missingPaths;
+ $requiredPaths[$index] = ['path' => $requiredPath, 'missing' => $missingPaths];
+ } else {
+ $requiredPaths[$index] = ['path' => $requiredPath];
}
}
}
diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml
index eda2c311917c0..560e9cc57b4ba 100755
--- a/setup/view/magento/setup/readiness-check/progress.phtml
+++ b/setup/view/magento/setup/readiness-check/progress.phtml
@@ -13,7 +13,7 @@
- Completed! You need to resolve these issues to continue.
+ Error! You need to resolve these issues to continue.
@@ -444,23 +444,19 @@
- The best way to resolve this is to allow write permissions for the following Magento
- directories and their sub-directories. The exact fix depends on your server, your host,
+ The best way to resolve this is to allow write permissions in. The exact fix depends on your server, your host,
and other system variables.
- Our File Permission Help can get you started.
-
-
- If you need more help, please call your hosting provider.
+ For help, see our File Permission Help or call your hosting provider.
-
+ ng-repeat="name in permissions.data.required"
+ ng-switch="hasItem(permissions.data.current, name.path)">
- "{{name}}"
+ "{{name.path}}"
- Writable.
@@ -470,7 +466,7 @@
Show details
Hide details
-
+
-
{{file}}
From 8a065cbc2aa15bfd25e0198a3c637cab04c896af Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Wed, 20 Apr 2016 15:29:10 -0500
Subject: [PATCH 37/52] MAGETWO-51580: Misleading error messages during
installation
- fixed text
---
setup/view/magento/setup/readiness-check/progress.phtml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml
index 560e9cc57b4ba..e6498eaafbbf5 100755
--- a/setup/view/magento/setup/readiness-check/progress.phtml
+++ b/setup/view/magento/setup/readiness-check/progress.phtml
@@ -444,7 +444,7 @@
- The best way to resolve this is to allow write permissions in. The exact fix depends on your server, your host,
+ The best way to resolve this is to allow write permissions for files in the following Magento directories and subdirectories. The exact fix depends on your server, your host,
and other system variables.
For help, see our File Permission Help or call your hosting provider.
From d9fd5f963206a37f54a7d9ee2060a78adb0775d9 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Thu, 21 Apr 2016 19:10:41 -0500
Subject: [PATCH 38/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- adding area
---
.../Setup/Console/Command/UpgradeCommand.php | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
index 44064e4b9409f..afbcf823f7043 100644
--- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
@@ -5,8 +5,10 @@
*/
namespace Magento\Setup\Console\Command;
+use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Setup\ConsoleLogger;
use Magento\Setup\Model\InstallerFactory;
+use Magento\Setup\Model\ObjectManagerProvider;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@@ -28,14 +30,23 @@ class UpgradeCommand extends AbstractSetupCommand
*/
private $installerFactory;
+ /**
+ * Object Manager
+ *
+ * @var ObjectManagerInterface
+ */
+ private $objectManager;
+
/**
* Constructor
*
* @param InstallerFactory $installerFactory
+ * @param ObjectManagerProvider $objectManagerProvider
*/
- public function __construct(InstallerFactory $installerFactory)
+ public function __construct(InstallerFactory $installerFactory, ObjectManagerProvider $objectManagerProvider)
{
$this->installerFactory = $installerFactory;
+ $this->objectManager = $objectManagerProvider->get();
parent::__construct();
}
@@ -65,6 +76,10 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $areaCode = 'adminhtml';
+ /** @var \Magento\Framework\App\State $appState */
+ $appState = $this->objectManager->get('Magento\Framework\App\State');
+ $appState->setAreaCode($areaCode);
$keepGenerated = $input->getOption(self::INPUT_KEY_KEEP_GENERATED);
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->updateModulesSequence($keepGenerated);
From f6d902fedd8972dfd6e1c592ef4b2c1660b9ca3d Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Thu, 21 Apr 2016 19:15:53 -0500
Subject: [PATCH 39/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- adding area
---
.../Test/Unit/Console/Command/UpgradeCommandTest.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
index 46ebded67b6ec..ca70d9c3ae471 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
@@ -13,12 +13,18 @@ class UpgradeCommandTest extends \PHPUnit_Framework_TestCase
public function testExecute()
{
$installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false);
+ $objectManagerProvider = $this->getMock('\Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
+ $objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface');
+ $state = $this->getMock('Magento\Framework\App\State', [], [], '', false);
+ $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
+ $objectManager->expects($this->once())->method('get')->willReturn($state);
+ $state->expects($this->once())->method('setAreaCode')->with('adminhtml');
$installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false);
$installer->expects($this->at(0))->method('updateModulesSequence');
$installer->expects($this->at(1))->method('installSchema');
$installer->expects($this->at(2))->method('installDataFixtures');
$installerFactory->expects($this->once())->method('create')->willReturn($installer);
- $commandTester = new CommandTester(new UpgradeCommand($installerFactory));
+ $commandTester = new CommandTester(new UpgradeCommand($installerFactory, $objectManagerProvider));
$commandTester->execute([]);
}
}
From 957a1dd4a00481958ac29a402380f19a9790cfd7 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 25 Apr 2016 11:51:27 -0500
Subject: [PATCH 40/52] MAGETWO-51580: Misleading error messages during
installation
- added test.
- CR recommend refactor
---
.../Framework/Setup/FilePermissions.php | 21 +++++++++++++------
.../Magento/Setup/Controller/Environment.php | 21 +++++--------------
.../Test/Unit/Controller/EnvironmentTest.php | 17 +++++++++++++++
3 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php
index b27d74392a1c3..2f30a626253db 100644
--- a/lib/internal/Magento/Framework/Setup/FilePermissions.php
+++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php
@@ -226,23 +226,32 @@ protected function isReadableDirectory($directory)
}
/**
- * Checks writable paths for installation
+ * Checks writable paths for installation, returns associative array if input is true, else returns simple array
*
+ * @param bool $associative
* @return array
*/
- public function getMissingWritablePathsForInstallation()
+ public function getMissingWritablePathsForInstallation($associative = false)
{
$required = $this->getInstallationWritableDirectories();
$current = $this->getInstallationCurrentWritableDirectories();
$missingPaths = [];
foreach (array_diff($required, $current) as $missingPath) {
if (isset($this->nonWritablePathsInDirectories[$missingPath])) {
- $missingPaths = array_merge(
- $missingPaths,
- $this->nonWritablePathsInDirectories[$missingPath]
- );
+ if ($associative) {
+ $missingPaths[$missingPath] = $this->nonWritablePathsInDirectories[$missingPath];
+ } else {
+ $missingPaths = array_merge(
+ $missingPaths,
+ $this->nonWritablePathsInDirectories[$missingPath]
+ );
+ }
}
}
+ if ($associative) {
+ $required = array_flip($required);
+ $missingPaths = array_merge($required, $missingPaths);
+ }
return $missingPaths;
}
diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php
index 09e383f8ff13d..a68cbd2220e9b 100644
--- a/setup/src/Magento/Setup/Controller/Environment.php
+++ b/setup/src/Magento/Setup/Controller/Environment.php
@@ -160,24 +160,13 @@ private function getPhpChecksInfo($type)
public function filePermissionsAction()
{
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
- $missingWritePermissionPaths = $this->permissions->getMissingWritablePathsForInstallation();
- $requiredPaths = $this->permissions->getInstallationWritableDirectories();
+ $missingWritePermissionPaths = $this->permissions->getMissingWritablePathsForInstallation(true);
+
+ $requiredPaths = [];
if ($missingWritePermissionPaths) {
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
-
- foreach ($requiredPaths as $index => $requiredPath) {
- $missingPaths = [];
- foreach ($missingWritePermissionPaths as $missingWritePermissionPath) {
- if (strpos($missingWritePermissionPath, $requiredPath) === 0) {
- $missingPaths[] = $missingWritePermissionPath;
- }
- }
- unset($requiredPaths[$index]);
- if (!empty($missingPaths)) {
- $requiredPaths[$index] = ['path' => $requiredPath, 'missing' => $missingPaths];
- } else {
- $requiredPaths[$index] = ['path' => $requiredPath];
- }
+ foreach($missingWritePermissionPaths as $key => $value) {
+ $requiredPaths[] = ['path' => $key, 'missing' => $value];
}
}
$data = [
diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php
index 5509808523dbb..7fd01dcd2016c 100644
--- a/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Controller/EnvironmentTest.php
@@ -58,6 +58,23 @@ public function setUp()
);
}
+ public function testFilePermissionsInstaller()
+ {
+ $request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false);
+ $response = $this->getMock('\Zend\Http\PhpEnvironment\Response', [], [], '', false);
+ $routeMatch = $this->getMock('\Zend\Mvc\Router\RouteMatch', [], [], '', false);
+
+ $mvcEvent = $this->getMock('\Zend\Mvc\MvcEvent', [], [], '', false);
+ $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent);
+ $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent);
+ $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent);
+ $mvcEvent->expects($this->any())->method('getRouteMatch')->willReturn($routeMatch);
+ $this->permissions->expects($this->once())->method('getMissingWritablePathsForInstallation');
+ $this->environment->setEvent($mvcEvent);
+ $this->environment->dispatch($request, $response);
+ $this->environment->filePermissionsAction();
+ }
+
public function testPhpVersionActionInstaller()
{
$request = $this->getMock('\Zend\Http\PhpEnvironment\Request', [], [], '', false);
From e754922e832de6e5ffaa961e112041e28e5f55d0 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Mon, 25 Apr 2016 14:36:22 -0500
Subject: [PATCH 41/52] MAGETWO-51580: Misleading error messages during
installation
- fixing static test failure.
---
setup/src/Magento/Setup/Controller/Environment.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php
index a68cbd2220e9b..9d574f6de136f 100644
--- a/setup/src/Magento/Setup/Controller/Environment.php
+++ b/setup/src/Magento/Setup/Controller/Environment.php
@@ -165,7 +165,7 @@ public function filePermissionsAction()
$requiredPaths = [];
if ($missingWritePermissionPaths) {
$responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
- foreach($missingWritePermissionPaths as $key => $value) {
+ foreach ($missingWritePermissionPaths as $key => $value) {
$requiredPaths[] = ['path' => $key, 'missing' => $value];
}
}
From 571836934b2b8b09a49753a90e8cd418869ee9a6 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 08:40:16 -0500
Subject: [PATCH 42/52] MAGETWO-51580: Misleading error messages during
installation
- fixing functional tests
---
.../Test/Constraint/AssertSuccessfulReadinessCheck.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php b/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php
index 05c9379cf1c3f..1a7847e55107d 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php
@@ -27,7 +27,7 @@ class AssertSuccessfulReadinessCheck extends AbstractConstraint
/**
* File permission message.
*/
- const FILE_PERMISSION_REGEXP = '/You meet (\d+) out of \1 writable file permission requirements\./';
+ const FILE_PERMISSION_REGEXP = 'File permissions does not meet requirements.';
/**
* Assert that PHP Version, PHP Extensions and File Permission are ok.
@@ -47,7 +47,7 @@ public function processAssert(Install $installPage)
$installPage->getReadinessBlock()->getPhpExtensionsCheck(),
'PHP extensions missed.'
);
- \PHPUnit_Framework_Assert::assertRegExp(
+ \PHPUnit_Framework_Assert::assertContains(
self::FILE_PERMISSION_REGEXP,
$installPage->getReadinessBlock()->getFilePermissionCheck(),
'File permissions does not meet requirements.'
From d40b86d70e59b88788124ef533e7455b5b8139ca Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 14:50:41 -0500
Subject: [PATCH 43/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR changes.
---
.../Setup/Console/Command/UpgradeCommand.php | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
index afbcf823f7043..58471ad3c0eef 100644
--- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
@@ -33,9 +33,9 @@ class UpgradeCommand extends AbstractSetupCommand
/**
* Object Manager
*
- * @var ObjectManagerInterface
+ * @var ObjectManagerProvider
*/
- private $objectManager;
+ private $objectManagerProvider;
/**
* Constructor
@@ -46,7 +46,7 @@ class UpgradeCommand extends AbstractSetupCommand
public function __construct(InstallerFactory $installerFactory, ObjectManagerProvider $objectManagerProvider)
{
$this->installerFactory = $installerFactory;
- $this->objectManager = $objectManagerProvider->get();
+ $this->objectManagerProvider = $objectManagerProvider;
parent::__construct();
}
@@ -76,10 +76,16 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ /** @var \Magento\Framework\ObjectManagerInterface $objectManager */
+ $objectManager = $this->objectManagerProvider->get();
$areaCode = 'adminhtml';
/** @var \Magento\Framework\App\State $appState */
- $appState = $this->objectManager->get('Magento\Framework\App\State');
+ $appState = $objectManager->get('Magento\Framework\App\State');
$appState->setAreaCode($areaCode);
+ /** @var \Magento\Framework\ObjectManager\ConfigLoaderInterface $configLoader */
+ $configLoader = $objectManager->get('Magento\Framework\ObjectManager\ConfigLoaderInterface');
+ $objectManager->configure($configLoader->load($areaCode));
+
$keepGenerated = $input->getOption(self::INPUT_KEY_KEEP_GENERATED);
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->updateModulesSequence($keepGenerated);
From cce4f526d8381aef12a6d2d48ca319ee69ce7f3c Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 14:51:10 -0500
Subject: [PATCH 44/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR changes.
---
setup/src/Magento/Setup/Console/Command/UpgradeCommand.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
index 58471ad3c0eef..c4ca7c833394b 100644
--- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
@@ -78,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
$objectManager = $this->objectManagerProvider->get();
- $areaCode = 'adminhtml';
+ $areaCode = 'setup';
/** @var \Magento\Framework\App\State $appState */
$appState = $objectManager->get('Magento\Framework\App\State');
$appState->setAreaCode($areaCode);
From 6b90fc80349720977c70ca5baef88fc62e6a3cab Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 15:05:48 -0500
Subject: [PATCH 45/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- CR changes.
---
.../Setup/Test/Unit/Console/Command/UpgradeCommandTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
index ca70d9c3ae471..134993aa2f2cf 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
@@ -18,7 +18,7 @@ public function testExecute()
$state = $this->getMock('Magento\Framework\App\State', [], [], '', false);
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
$objectManager->expects($this->once())->method('get')->willReturn($state);
- $state->expects($this->once())->method('setAreaCode')->with('adminhtml');
+ $state->expects($this->once())->method('setAreaCode')->with('setup');
$installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false);
$installer->expects($this->at(0))->method('updateModulesSequence');
$installer->expects($this->at(1))->method('installSchema');
From c50d42c792a591daf20c03aece97a31b4db56a7b Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 16:09:34 -0500
Subject: [PATCH 46/52] MAGETWO-51580: Misleading error messages during
installation
- fixing functional tests
---
.../Constraint/AssertSuccessfulReadinessCheck.php | 4 ++--
setup/src/Magento/Setup/Controller/Environment.php | 12 +++++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php b/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php
index 1a7847e55107d..05c9379cf1c3f 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/Constraint/AssertSuccessfulReadinessCheck.php
@@ -27,7 +27,7 @@ class AssertSuccessfulReadinessCheck extends AbstractConstraint
/**
* File permission message.
*/
- const FILE_PERMISSION_REGEXP = 'File permissions does not meet requirements.';
+ const FILE_PERMISSION_REGEXP = '/You meet (\d+) out of \1 writable file permission requirements\./';
/**
* Assert that PHP Version, PHP Extensions and File Permission are ok.
@@ -47,7 +47,7 @@ public function processAssert(Install $installPage)
$installPage->getReadinessBlock()->getPhpExtensionsCheck(),
'PHP extensions missed.'
);
- \PHPUnit_Framework_Assert::assertContains(
+ \PHPUnit_Framework_Assert::assertRegExp(
self::FILE_PERMISSION_REGEXP,
$installPage->getReadinessBlock()->getFilePermissionCheck(),
'File permissions does not meet requirements.'
diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php
index 9d574f6de136f..fec3a7c4bc638 100644
--- a/setup/src/Magento/Setup/Controller/Environment.php
+++ b/setup/src/Magento/Setup/Controller/Environment.php
@@ -162,18 +162,24 @@ public function filePermissionsAction()
$responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS;
$missingWritePermissionPaths = $this->permissions->getMissingWritablePathsForInstallation(true);
+ $currentPaths = [];
$requiredPaths = [];
if ($missingWritePermissionPaths) {
- $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
foreach ($missingWritePermissionPaths as $key => $value) {
- $requiredPaths[] = ['path' => $key, 'missing' => $value];
+ if (is_array($value)) {
+ $requiredPaths[] = ['path' => $key, 'missing' => $value];
+ $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR;
+ } else {
+ $requiredPaths[] = ['path' => $key];
+ $currentPaths[] = $key;
+ }
}
}
$data = [
'responseType' => $responseType,
'data' => [
'required' => $requiredPaths,
- 'current' => $this->permissions->getInstallationCurrentWritableDirectories(),
+ 'current' => $currentPaths,
],
];
From cf7cad663265d52cf162c53e025e87fb039b6afe Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 16:19:04 -0500
Subject: [PATCH 47/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- fixing test
---
.../Test/Unit/Console/Command/UpgradeCommandTest.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
index 134993aa2f2cf..b607c30ee3a0f 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
@@ -15,9 +15,17 @@ public function testExecute()
$installerFactory = $this->getMock('Magento\Setup\Model\InstallerFactory', [], [], '', false);
$objectManagerProvider = $this->getMock('\Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
$objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface');
+ $configLoader = $this->getMockForAbstractClass('Magento\Framework\ObjectManager\ConfigLoaderInterface');
+ $configLoader->expects($this->once())->method('load')->willReturn(['some_key' => 'some_value']);
$state = $this->getMock('Magento\Framework\App\State', [], [], '', false);
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
- $objectManager->expects($this->once())->method('get')->willReturn($state);
+ $objectManager->expects($this->exactly(2))
+ ->method('get')
+ ->will($this->returnValueMap([
+ ['Magento\Framework\App\State', $state],
+ ['Magento\Framework\ObjectManager\ConfigLoaderInterface', $configLoader],
+ ]));
+ $objectManager->expects($this->once())->method('configure');
$state->expects($this->once())->method('setAreaCode')->with('setup');
$installer = $this->getMock('Magento\Setup\Model\Installer', [], [], '', false);
$installer->expects($this->at(0))->method('updateModulesSequence');
From e6db4f398621874e06603af70b9ffd1ebf3744a1 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Tue, 26 Apr 2016 16:20:38 -0500
Subject: [PATCH 48/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- fixing test
---
.../Setup/Test/Unit/Console/Command/UpgradeCommandTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
index b607c30ee3a0f..1b493e9cf330c 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/UpgradeCommandTest.php
@@ -18,6 +18,7 @@ public function testExecute()
$configLoader = $this->getMockForAbstractClass('Magento\Framework\ObjectManager\ConfigLoaderInterface');
$configLoader->expects($this->once())->method('load')->willReturn(['some_key' => 'some_value']);
$state = $this->getMock('Magento\Framework\App\State', [], [], '', false);
+ $state->expects($this->once())->method('setAreaCode')->with('setup');
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
$objectManager->expects($this->exactly(2))
->method('get')
From 8d0758c7701909a99ec5ac92ac217c4a1485bde7 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Thu, 28 Apr 2016 12:25:11 -0500
Subject: [PATCH 49/52] MAGETWO-52371: Marketplace credentials are exposed via
URL
- removal of password from json response.
---
setup/src/Magento/Setup/Controller/Marketplace.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup/src/Magento/Setup/Controller/Marketplace.php b/setup/src/Magento/Setup/Controller/Marketplace.php
index e7c2bbc441931..2bb5ba8963201 100644
--- a/setup/src/Magento/Setup/Controller/Marketplace.php
+++ b/setup/src/Magento/Setup/Controller/Marketplace.php
@@ -90,12 +90,12 @@ public function checkAuthAction()
);
$isValid = json_decode($isValid, true);
if ($isValid['success'] === true) {
- return new JsonModel(['success' => true, 'data' => $authDataJson]);
+ return new JsonModel(['success' => true, 'data' => ['username' => $authDataJson['username']]]);
} else {
return new JsonModel(['success' => false, 'message' => $isValid['message']]);
}
}
- return new JsonModel(['success' => false, 'data' => $authDataJson]);
+ return new JsonModel(['success' => false, 'data' => ['username' => $authDataJson['username']]]);
} catch (\Exception $e) {
return new JsonModel(['success' => false, 'message' => $e->getMessage()]);
}
From 81defe907a8df8137459b88068723ce8ef95fb60 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 29 Apr 2016 11:42:46 -0500
Subject: [PATCH 50/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- fixing virtual type names
---
app/code/Magento/Braintree/etc/di.xml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Braintree/etc/di.xml b/app/code/Magento/Braintree/etc/di.xml
index 000713c0b975d..e3fee681cc1c1 100644
--- a/app/code/Magento/Braintree/etc/di.xml
+++ b/app/code/Magento/Braintree/etc/di.xml
@@ -39,7 +39,7 @@
-
+
Magento\Braintree\Gateway\Config\Config
@@ -164,22 +164,22 @@
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
@@ -375,7 +375,7 @@
-
+
- Magento\Braintree\Model\Report\TransactionsCollection
@@ -385,7 +385,7 @@
- BraintreeTransactionsCollectionFactory
+ BraintreeTransactionsCollectionFactoryForReporting
From 5cb00c084c8a273b1ce24bd24408452b03ef0990 Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 29 Apr 2016 11:42:46 -0500
Subject: [PATCH 51/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- fixing virtual type names
---
app/code/Magento/Braintree/etc/di.xml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Braintree/etc/di.xml b/app/code/Magento/Braintree/etc/di.xml
index 000713c0b975d..e3fee681cc1c1 100644
--- a/app/code/Magento/Braintree/etc/di.xml
+++ b/app/code/Magento/Braintree/etc/di.xml
@@ -39,7 +39,7 @@
-
+
Magento\Braintree\Gateway\Config\Config
@@ -164,22 +164,22 @@
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
- BraintreeLogger
+ BraintreeLoggerForTransactionSale
@@ -375,7 +375,7 @@
-
+
- Magento\Braintree\Model\Report\TransactionsCollection
@@ -385,7 +385,7 @@
- BraintreeTransactionsCollectionFactory
+ BraintreeTransactionsCollectionFactoryForReporting
From 86fc062795575fb74c17d8df1c6a17f8f2565dcf Mon Sep 17 00:00:00 2001
From: Maddy Chellathurai
Date: Fri, 29 Apr 2016 14:07:30 -0500
Subject: [PATCH 52/52] MAGETWO-50934: setup:upgrade failed during CLI upgrade
from CE 2.0.x to 2.1.0
- merge conflicts fixes
---
.../Command/AbstractModuleManageCommand.php | 30 ++++++++++---------
.../ModuleEnableDisableCommandTest.php | 8 ++++-
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
index 2f8975a1a40aa..923ab86506dbd 100644
--- a/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/AbstractModuleManageCommand.php
@@ -24,25 +24,13 @@ abstract class AbstractModuleManageCommand extends AbstractModuleCommand
/**
* @var GeneratedFiles
*/
- private $generatedFiles;
+ protected $generatedFiles;
/**
* @var DeploymentConfig
*/
protected $deploymentConfig;
- /**
- * Constructor
- *
- * @param GeneratedFiles $generatedFiles
- * @param ObjectManagerProvider $objectManagerProvider
- */
- public function __construct(GeneratedFiles $generatedFiles, ObjectManagerProvider $objectManagerProvider)
- {
- $this->generatedFiles = $generatedFiles;
- parent::__construct($objectManagerProvider);
- }
-
/**
* {@inheritdoc}
*/
@@ -110,6 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$this->setIsEnabled($isEnable, $modulesToChange, $output);
$this->cleanup($input, $output);
+ $this->getGeneratedFiles()->requestRegeneration();
if ($force) {
$output->writeln(
'Alert: You used the --force option.'
@@ -147,7 +136,6 @@ private function setIsEnabled($isEnable, $modulesToChange, $output)
$output->writeln('- ' . implode("\n- ", $modulesToChange) . '');
$output->writeln('');
}
- $this->generatedFiles->requestRegeneration();
}
/**
@@ -196,4 +184,18 @@ private function getDeploymentConfig()
}
return $this->deploymentConfig;
}
+
+ /**
+ * Get deployment config
+ *
+ * @return GeneratedFiles
+ * @deprecated
+ */
+ private function getGeneratedFiles()
+ {
+ if (!($this->generatedFiles instanceof GeneratedFiles)) {
+ return $this->objectManager->get(GeneratedFiles::class);
+ }
+ return $this->generatedFiles;
+ }
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
index f7b10a936daf1..c5441bc89cebf 100644
--- a/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Console/Command/ModuleEnableDisableCommandTest.php
@@ -9,6 +9,9 @@
use Magento\Setup\Console\Command\ModuleEnableCommand;
use Symfony\Component\Console\Tester\CommandTester;
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class ModuleEnableDisableCommandTest extends \PHPUnit_Framework_TestCase
{
/**
@@ -319,10 +322,13 @@ public function testExecuteNoChanges($isEnable)
private function getCommandTester($isEnable)
{
$class = $isEnable ? ModuleEnableCommand::class : ModuleDisableCommand::class;
- $command = new $class($this->generatedFiles, $this->objectManagerProviderMock);
+ $command = new $class($this->objectManagerProviderMock);
$deploymentConfigProperty = new \ReflectionProperty($class, 'deploymentConfig');
$deploymentConfigProperty->setAccessible(true);
$deploymentConfigProperty->setValue($command, $this->deploymentConfigMock);
+ $deploymentConfigProperty = new \ReflectionProperty($class, 'generatedFiles');
+ $deploymentConfigProperty->setAccessible(true);
+ $deploymentConfigProperty->setValue($command, $this->generatedFiles);
return new CommandTester($command);
}
}