Skip to content

Commit afef5a7

Browse files
committed
Merge remote-tracking branch 'ogresCE/MAGETWO-44042-issues-after-create-project' into PR_Branch
2 parents 0e66366 + 2f3c26d commit afef5a7

File tree

5 files changed

+59
-105
lines changed

5 files changed

+59
-105
lines changed

setup/pub/magento/setup/readiness-check.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ angular.module('readiness-check', [])
156156
process: function(data) {
157157
$scope.extensions.processed = true;
158158
angular.extend($scope.extensions, data);
159-
$scope.extensions.length = Object.keys($scope.extensions.data.required).length;
159+
if(data.responseType !== 'error') {
160+
$scope.extensions.length = Object.keys($scope.extensions.data.required).length;
161+
}
160162
$scope.updateOnProcessed($scope.extensions.responseType);
161163
$scope.stopProgress();
162164
},

setup/src/Magento/Setup/Controller/Connect.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public function saveAuthJsonAction()
5151
$password = isset($params['password']) ? $params['password'] : '';
5252
$isValid = $this->connectManager->checkCredentialsAction($userName, $password);
5353
$isValid = json_decode($isValid, true);
54-
if ($isValid['success'] === true) {
55-
$this->connectManager->saveAuthJson($userName, $password);
54+
if ($isValid['success'] === true && $this->connectManager->saveAuthJson($userName, $password)) {
5655
return new JsonModel(['success' => true]);
5756
} else {
5857
return new JsonModel(['success' => false, 'message' => $isValid['message']]);

setup/src/Magento/Setup/Model/ConnectManager.php

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Zend\ServiceManager\ServiceLocatorInterface;
1010
use Magento\Framework\App\Filesystem\DirectoryList;
1111
use Magento\Framework\Filesystem;
12+
use Zend\View\Model\JsonModel;
1213

1314
class ConnectManager
1415
{
@@ -43,14 +44,11 @@ class ConnectManager
4344
private $pathToAuthFile = 'auth.json';
4445

4546
/**#@+
46-
* Composer command params and options
47+
* Composer auth.json keys
4748
*/
48-
const PARAM_COMMAND = 'command';
49-
const PARAM_KEY = 'setting-key';
50-
const PARAM_VALUE = 'setting-value';
51-
const PARAM_GLOBAL = '--global';
52-
const PARAM_CONFIG = 'config';
53-
const PARAM_HTTPBASIC = 'http-basic.';
49+
const KEY_HTTPBASIC = 'http-basic';
50+
const KEY_USERNAME = 'username';
51+
const KEY_PASSWORD = 'password';
5452

5553
/**
5654
* @var \Magento\Framework\Filesystem\Directory\Write
@@ -62,31 +60,23 @@ class ConnectManager
6260
*/
6361
protected $pathToInstallPackagesCacheFile = 'install_composer_packages.json';
6462

65-
/**
66-
* @var \Magento\Composer\MagentoComposerApplication
67-
*/
68-
protected $application;
69-
7063
/**
7164
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
7265
* @param \Magento\Framework\Composer\ComposerInformation $composerInformation
7366
* @param \Magento\Framework\HTTP\Client\Curl $curl
7467
* @param \Magento\Framework\Filesystem $filesystem
75-
* @param \Magento\Framework\Composer\MagentoComposerApplicationFactory $applicationFactory
7668
*/
7769
public function __construct(
7870
\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator,
7971
\Magento\Framework\Composer\ComposerInformation $composerInformation,
8072
\Magento\Framework\HTTP\Client\Curl $curl,
81-
\Magento\Framework\Filesystem $filesystem,
82-
\Magento\Framework\Composer\MagentoComposerApplicationFactory $applicationFactory
73+
\Magento\Framework\Filesystem $filesystem
8374
) {
8475
$this->serviceLocator = $serviceLocator;
8576
$this->composerInformation = $composerInformation;
8677
$this->curlClient = $curl;
8778
$this->filesystem = $filesystem;
8879
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
89-
$this->application = $applicationFactory->create();
9080
}
9181

9282
/**
@@ -260,18 +250,27 @@ public function removeCredentials()
260250
*/
261251
public function saveAuthJson($username, $password)
262252
{
263-
$commandParams = [
264-
self::PARAM_COMMAND => self::PARAM_CONFIG,
265-
self::PARAM_KEY => self::PARAM_HTTPBASIC . $this->getCredentialBaseUrl(),
266-
self::PARAM_VALUE => [$username, $password],
267-
self::PARAM_GLOBAL => true
253+
$authContent = [
254+
self::KEY_HTTPBASIC => [
255+
$this->getCredentialBaseUrl() => [
256+
self::KEY_USERNAME => "$username",
257+
self::KEY_PASSWORD => "$password"
258+
]
259+
]
268260
];
269-
try {
270-
$this->getApplication()->runComposerCommand($commandParams);
271-
return true;
272-
} catch (\Magento\Framework\Exception\FileSystemException $e) {
273-
throw new \Exception($e->getMessage());
274-
}
261+
$json = new JsonModel($authContent);
262+
$json->setOption('prettyPrint', true);
263+
$jsonContent = $json->serialize();
264+
265+
return $this->getDirectory()->writeFile(
266+
DirectoryList::COMPOSER_HOME . DIRECTORY_SEPARATOR . $this->pathToAuthFile,
267+
$jsonContent
268+
) && $this->getDirectory()->changePermissions(
269+
DirectoryList::COMPOSER_HOME . DIRECTORY_SEPARATOR . $this->pathToAuthFile,
270+
\Magento\Framework\Filesystem\DriverInterface::WRITEABLE_FILE_MODE
271+
);
272+
273+
return false;
275274
}
276275

277276
/**
@@ -383,12 +382,4 @@ public function getDirectory()
383382
{
384383
return $this->directory;
385384
}
386-
387-
/**
388-
* @return \Magento\Composer\MagentoComposerApplication
389-
*/
390-
public function getApplication()
391-
{
392-
return $this->application;
393-
}
394385
}

setup/src/Magento/Setup/Test/Unit/Controller/ConnectTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public function testSaveAuthJsonAction()
4646
->will($this->returnValue(\Zend_Json::encode(['success' => true])));
4747
$this->connectManager
4848
->expects($this->once())
49-
->method('saveAuthJson');
49+
->method('saveAuthJson')
50+
->willReturn(true);
5051
$jsonModel = $this->controller->saveAuthJsonAction();
5152
$this->assertInstanceOf('Zend\View\Model\ViewModel', $jsonModel);
5253
$variables = $jsonModel->getVariables();

setup/src/Magento/Setup/Test/Unit/Model/ConnectManagerTest.php

Lines changed: 27 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class ConnectManagerTest extends \PHPUnit_Framework_TestCase
2626

2727
private $composerInformationMock;
2828

29-
private $applicationFactoryMock;
30-
3129
public function setUp()
3230
{
3331
$this->serviceLocatorMock = $this->_getServiceLocatorMock();
@@ -36,7 +34,6 @@ public function setUp()
3634
);
3735
$this->curlClientMock = $this->_getCurlClientMock(['setCredentials', 'getBody', 'post']);
3836
$this->filesystemMock = $this->_getFilesystemMock(['getDirectoryRead', 'getDirectoryWrite']);
39-
$this->applicationFactoryMock = $this->_getApplicationFactoryMock(['create']);
4037
}
4138

4239
/**
@@ -50,8 +47,7 @@ public function testGetCheckCredentialUrl()
5047
$this->serviceLocatorMock,
5148
$this->composerInformationMock,
5249
$this->curlClientMock,
53-
$this->filesystemMock,
54-
$this->applicationFactoryMock
50+
$this->filesystemMock
5551
]
5652
);
5753
$connectManager
@@ -76,8 +72,7 @@ public function testGetCredentialBaseUrl()
7672
$this->serviceLocatorMock,
7773
$this->composerInformationMock,
7874
$this->curlClientMock,
79-
$this->filesystemMock,
80-
$this->applicationFactoryMock
75+
$this->filesystemMock
8176
]
8277
);
8378
$this->serviceLocatorMock
@@ -107,8 +102,7 @@ public function testGetPackagesJsonUrl()
107102
$this->serviceLocatorMock,
108103
$this->composerInformationMock,
109104
$this->curlClientMock,
110-
$this->filesystemMock,
111-
$this->applicationFactoryMock
105+
$this->filesystemMock
112106
]
113107
);
114108
$connectManager
@@ -136,8 +130,7 @@ public function testCheckCredentialsAction()
136130
$this->serviceLocatorMock,
137131
$this->composerInformationMock,
138132
$this->curlClientMock,
139-
$this->filesystemMock,
140-
$this->applicationFactoryMock
133+
$this->filesystemMock
141134
]
142135
);
143136
$this->curlClientMock
@@ -172,8 +165,7 @@ public function testCheckCredentialsActionWithException()
172165
$this->serviceLocatorMock,
173166
$this->composerInformationMock,
174167
$this->curlClientMock,
175-
$this->filesystemMock,
176-
$this->applicationFactoryMock
168+
$this->filesystemMock
177169
]
178170
);
179171
$this->curlClientMock
@@ -214,8 +206,7 @@ public function testGetPackagesJson()
214206
$this->serviceLocatorMock,
215207
$this->composerInformationMock,
216208
$this->curlClientMock,
217-
$this->filesystemMock,
218-
$this->applicationFactoryMock
209+
$this->filesystemMock
219210
]
220211
);
221212
$this->curlClientMock
@@ -255,8 +246,7 @@ public function testGetPackagesJsonWithException()
255246
$this->serviceLocatorMock,
256247
$this->composerInformationMock,
257248
$this->curlClientMock,
258-
$this->filesystemMock,
259-
$this->applicationFactoryMock
249+
$this->filesystemMock
260250
]
261251
);
262252
$this->curlClientMock
@@ -301,8 +291,7 @@ public function testSyncPackagesForInstall()
301291
$this->serviceLocatorMock,
302292
$this->composerInformationMock,
303293
$this->curlClientMock,
304-
$this->filesystemMock,
305-
$this->applicationFactoryMock
294+
$this->filesystemMock
306295
]
307296
);
308297
$connectManager
@@ -378,8 +367,7 @@ public function testGetAuthJsonData()
378367
$this->serviceLocatorMock,
379368
$this->composerInformationMock,
380369
$this->curlClientMock,
381-
$this->filesystemMock,
382-
$this->applicationFactoryMock
370+
$this->filesystemMock
383371
]
384372
);
385373
$connectManager
@@ -414,8 +402,7 @@ public function testGetAuthJson()
414402
$this->serviceLocatorMock,
415403
$this->composerInformationMock,
416404
$this->curlClientMock,
417-
$this->filesystemMock,
418-
$this->applicationFactoryMock
405+
$this->filesystemMock
419406
]
420407
);
421408
$directory = $this->_getDirectoryMock();
@@ -460,8 +447,7 @@ public function testRemoveCredentials()
460447
$this->serviceLocatorMock,
461448
$this->composerInformationMock,
462449
$this->curlClientMock,
463-
$this->filesystemMock,
464-
$this->applicationFactoryMock
450+
$this->filesystemMock
465451
]
466452
);
467453
$directory = $this->_getDirectoryMock();
@@ -526,8 +512,7 @@ public function testRemoveCredentialsEmptyHttpbasic()
526512
$this->serviceLocatorMock,
527513
$this->composerInformationMock,
528514
$this->curlClientMock,
529-
$this->filesystemMock,
530-
$this->applicationFactoryMock
515+
$this->filesystemMock
531516
]
532517
);
533518
$directory = $this->_getDirectoryMock();
@@ -573,25 +558,27 @@ public function testSaveAuthJson()
573558
{
574559
$connectManager = $this->_getConnectManagerMock(
575560
[
561+
'getDirectory',
576562
'getCredentialBaseUrl',
577563
'getApplication'
578564
],
579565
[
580566
$this->serviceLocatorMock,
581567
$this->composerInformationMock,
582568
$this->curlClientMock,
583-
$this->filesystemMock,
584-
$this->applicationFactoryMock
569+
$this->filesystemMock
585570
]
586571
);
587-
$application = $this->_getApplicationMock(['runComposerCommand']);
572+
573+
$directory = $this->_getDirectoryMock();
588574
$connectManager
589-
->expects($this->once())
590-
->method('getApplication')
591-
->will($this->returnValue($application));
592-
$this->applicationFactoryMock
593-
->expects($this->never())
594-
->method('runComposerCommand');
575+
->expects($this->any())
576+
->method('getDirectory')
577+
->will($this->returnValue($directory));
578+
$directory
579+
->expects($this->any())
580+
->method('writeFile')
581+
->will($this->returnValue($directory));
595582

596583
$connectManager->saveAuthJson('username', 'password');
597584
}
@@ -607,8 +594,7 @@ public function testSavePackagesForInstallToCache()
607594
$this->serviceLocatorMock,
608595
$this->composerInformationMock,
609596
$this->curlClientMock,
610-
$this->filesystemMock,
611-
$this->applicationFactoryMock
597+
$this->filesystemMock
612598
]
613599
);
614600
$directory = $this->_getDirectoryMock();
@@ -639,8 +625,7 @@ public function testGetPackagesForInstallEmptyData()
639625
$this->serviceLocatorMock,
640626
$this->composerInformationMock,
641627
$this->curlClientMock,
642-
$this->filesystemMock,
643-
$this->applicationFactoryMock
628+
$this->filesystemMock
644629
]
645630
);
646631
$connectManager
@@ -667,8 +652,7 @@ public function testGetPackagesForInstall()
667652
$this->serviceLocatorMock,
668653
$this->composerInformationMock,
669654
$this->curlClientMock,
670-
$this->filesystemMock,
671-
$this->applicationFactoryMock
655+
$this->filesystemMock
672656
]
673657
);
674658
$connectManager
@@ -703,8 +687,7 @@ public function testLoadPackagesForInstallFromCache()
703687
$this->serviceLocatorMock,
704688
$this->composerInformationMock,
705689
$this->curlClientMock,
706-
$this->filesystemMock,
707-
$this->applicationFactoryMock
690+
$this->filesystemMock
708691
]
709692
);
710693

@@ -782,28 +765,6 @@ protected function _getDirectoryMock()
782765
return $this->getMockForAbstractClass('\Magento\Framework\Filesystem\Directory\WriteInterface');
783766
}
784767

785-
/**
786-
* Gets ApplicationFactory mock
787-
*
788-
* @param null $methods
789-
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Composer\MagentoComposerApplicationFactory
790-
*/
791-
protected function _getApplicationFactoryMock($methods = null)
792-
{
793-
return $this->getMock('Magento\Framework\Composer\MagentoComposerApplicationFactory', $methods, [], '', false);
794-
}
795-
796-
/**
797-
* Gets Application mock
798-
*
799-
* @param null $methods
800-
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Composer\MagentoComposerApplication
801-
*/
802-
protected function _getApplicationMock($methods = null)
803-
{
804-
return $this->getMock('Magento\Composer\MagentoComposerApplication', $methods, [], '', false);
805-
}
806-
807768
/**
808769
* Gets ConnectManager mock
809770
*

0 commit comments

Comments
 (0)