Skip to content

Commit 495642b

Browse files
author
Volodymyr Zaets
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-50158
2 parents 7cb9e9f + 809df2c commit 495642b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+597
-1169
lines changed

dev/tests/integration/testsuite/Magento/Framework/Composer/ComposerInformationTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,30 @@ public function testIsPackageInComposerJson()
209209
$packageName = 'magento/wrong-module-name';
210210
$this->assertFalse($composerInfo->isPackageInComposerJson($packageName));
211211
}
212+
213+
/**
214+
* @param $composerDir string Directory under _files that contains composer files
215+
*
216+
* @dataProvider getRequiredPhpVersionDataProvider
217+
*/
218+
public function testGetRootRepositories($composerDir)
219+
{
220+
$this->setupDirectory($composerDir);
221+
222+
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
223+
$composerInfo = $this->objectManager->create(
224+
'Magento\Framework\Composer\ComposerInformation',
225+
[
226+
'applicationFactory' => new MagentoComposerApplicationFactory(
227+
$this->composerJsonFinder,
228+
$this->directoryList
229+
)
230+
]
231+
);
232+
if ($composerDir === 'testFromCreateProject') {
233+
$this->assertEquals(['https://repo.magento.com/'], $composerInfo->getRootRepositories());
234+
} else {
235+
$this->assertEquals([], $composerInfo->getRootRepositories());
236+
}
237+
}
212238
}

dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromCreateProject/composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
"require": {
1111
"magento/product-community-edition": "0.74.0-beta9"
1212
},
13+
"repositories": [
14+
{
15+
"type": "composer",
16+
"url": "https://repo.magento.com/"
17+
}
18+
],
1319
"require-dev": {
1420
"phpunit/phpunit": "4.1.0",
1521
"squizlabs/php_codesniffer": "1.5.3",

dev/tests/integration/testsuite/Magento/Setup/Model/UpdatePackagesCacheTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Magento\TestFramework\Helper\Bootstrap;
1010
use Magento\Framework\Composer\ComposerJsonFinder;
1111
use Magento\Framework\Composer\MagentoComposerApplicationFactory;
12-
use Magento\Setup\Model\UpdatePackagesCache;
1312

1413
/**
1514
* Tests Magento\Framework\ComposerInformation
@@ -81,12 +80,6 @@ public function testGetPackagesForUpdate()
8180

8281
$this->setupDirectory('testSkeleton');
8382

84-
$objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
85-
$objectManagerProvider
86-
->expects($this->any())
87-
->method('get')
88-
->willReturn($this->objectManager);
89-
9083
/** @var UpdatePackagesCache $updatePackagesCache|\PHPUnit_Framework_MockObject_MockObject */
9184
$updatePackagesCache = $this->getMock('Magento\Setup\Model\UpdatePackagesCache', [], [], '', false);
9285

dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\Api\Code\Generator\Mapper;
1111
use Magento\Framework\Api\Code\Generator\SearchResults;
12+
use Magento\Framework\App\Filesystem\DirectoryList;
1213
use Magento\Framework\Component\ComponentRegistrar;
1314
use Magento\Framework\ObjectManager\Code\Generator\Converter;
1415
use Magento\Framework\ObjectManager\Code\Generator\Factory;
@@ -42,11 +43,6 @@ class CompilerTest extends \PHPUnit_Framework_TestCase
4243
*/
4344
protected $_compilationDir;
4445

45-
/**
46-
* @var string
47-
*/
48-
protected $_tmpDir;
49-
5046
/**
5147
* @var \Magento\Framework\ObjectManager\Config\Mapper\Dom()
5248
*/
@@ -70,17 +66,11 @@ protected function setUp()
7066
$basePath = BP;
7167
$basePath = str_replace('\\', '/', $basePath);
7268

73-
$this->_tmpDir = realpath(__DIR__) . '/tmp';
74-
$this->_generationDir = $this->_tmpDir . '/generation';
75-
if (!file_exists($this->_generationDir)) {
76-
mkdir($this->_generationDir, 0777, true);
77-
}
78-
$this->_compilationDir = $this->_tmpDir . '/di';
79-
if (!file_exists($this->_compilationDir)) {
80-
mkdir($this->_compilationDir, 0777, true);
81-
}
69+
$directoryList = new DirectoryList($basePath);
70+
$this->_generationDir = $directoryList->getPath(DirectoryList::GENERATION);
71+
$this->_compilationDir = $directoryList->getPath(DirectoryList::DI);
8272

83-
$this->_command = 'php ' . $basePath . '/bin/magento setup:di:compile-multi-tenant --generation=%s --di=%s';
73+
$this->_command = 'php ' . $basePath . '/bin/magento setup:di:compile';
8474

8575
$booleanUtils = new \Magento\Framework\Stdlib\BooleanUtils();
8676
$constInterpreter = new \Magento\Framework\Data\Argument\Interpreter\Constant();
@@ -116,14 +106,6 @@ protected function setUp()
116106
$this->pluginValidator = new \Magento\Framework\Interception\Code\InterfaceValidator();
117107
}
118108

119-
protected function tearDown()
120-
{
121-
$filesystem = new \Magento\Framework\Filesystem\Driver\File();
122-
if ($filesystem->isExists($this->_tmpDir)) {
123-
$filesystem->deleteDirectory($this->_tmpDir);
124-
}
125-
}
126-
127109
/**
128110
* Validate DI config file
129111
*
@@ -412,7 +394,7 @@ protected function pluginDataProvider()
412394
public function testCompiler()
413395
{
414396
try {
415-
$this->_shell->execute($this->_command, [$this->_generationDir, $this->_compilationDir]);
397+
$this->_shell->execute($this->_command);
416398
} catch (\Magento\Framework\Exception\LocalizedException $exception) {
417399
$this->fail($exception->getPrevious()->getMessage());
418400
}

dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -247,117 +247,4 @@ public function testCopyPaste()
247247
"PHP Copy/Paste Detector has found error(s):" . PHP_EOL . $output
248248
);
249249
}
250-
251-
public function testDeadCode()
252-
{
253-
if (!class_exists('SebastianBergmann\PHPDCD\Analyser')) {
254-
$this->markTestSkipped('PHP Dead Code Detector is not available.');
255-
}
256-
$analyser = new \SebastianBergmann\PHPDCD\Analyser();
257-
$declared = [];
258-
$called = [];
259-
$collectedFiles = Files::init()->getPhpFiles(
260-
Files::INCLUDE_APP_CODE
261-
| Files::INCLUDE_PUB_CODE
262-
| Files::INCLUDE_LIBS
263-
| Files::INCLUDE_TEMPLATES
264-
| Files::INCLUDE_TESTS
265-
| Files::AS_DATA_SET
266-
| Files::INCLUDE_NON_CLASSES
267-
);
268-
foreach ($collectedFiles as $file) {
269-
$file = array_pop($file);
270-
$analyser->analyseFile($file);
271-
foreach ($analyser->getFunctionDeclarations() as $function => $declaration) {
272-
$declaration = $declaration; //avoid "unused local variable" error and non-effective array_keys call
273-
if (strpos($function, '::') === false) {
274-
$method = $function;
275-
} else {
276-
list($class, $method) = explode('::', $function);
277-
}
278-
$declared[$method] = $function;
279-
}
280-
foreach ($analyser->getFunctionCalls() as $function => $usages) {
281-
$usages = $usages; //avoid "unused local variable" error and non-effective array_keys call
282-
if (strpos($function, '::') === false) {
283-
$method = $function;
284-
} else {
285-
list($class, $method) = explode('::', $function);
286-
}
287-
$called[$method] = 1;
288-
}
289-
}
290-
291-
foreach ($called as $method => $value) {
292-
$value = $value; //avoid "unused local variable" error and non-effective array_keys call
293-
unset($declared[$method]);
294-
}
295-
$declared = $this->filterUsedObserverMethods($declared);
296-
$declared = $this->filterUsedPersistentObserverMethods($declared);
297-
$declared = $this->filterUsedCrontabObserverMethods($declared);
298-
if ($declared) {
299-
$this->fail('Dead code detected:' . PHP_EOL . implode(PHP_EOL, $declared));
300-
}
301-
}
302-
303-
/**
304-
* @param string[] $methods
305-
* @return string[]
306-
* @throws \Exception
307-
*/
308-
private function filterUsedObserverMethods($methods)
309-
{
310-
foreach (Files::init()->getConfigFiles('{*/events.xml,events.xml}') as $file) {
311-
$file = array_pop($file);
312-
313-
$doc = new \DOMDocument();
314-
$doc->load($file);
315-
foreach ($doc->getElementsByTagName('observer') as $observer) {
316-
/** @var \DOMElement $observer */
317-
$method = $observer->getAttribute('method');
318-
unset($methods[$method]);
319-
}
320-
}
321-
return $methods;
322-
}
323-
324-
/**
325-
* @param string[] $methods
326-
* @return string[]
327-
* @throws \Exception
328-
*/
329-
private function filterUsedPersistentObserverMethods($methods)
330-
{
331-
foreach (Files::init()->getConfigFiles('{*/persistent.xml,persistent.xml}') as $file) {
332-
$file = array_pop($file);
333-
334-
$doc = new \DOMDocument();
335-
$doc->load($file);
336-
foreach ($doc->getElementsByTagName('method') as $method) {
337-
/** @var \DOMElement $method */
338-
unset($methods[$method->textContent]);
339-
}
340-
}
341-
return $methods;
342-
}
343-
344-
/**
345-
* @param string[] $methods
346-
* @return string[]
347-
* @throws \Exception
348-
*/
349-
private function filterUsedCrontabObserverMethods($methods)
350-
{
351-
foreach (Files::init()->getConfigFiles('{*/crontab.xml,crontab.xml}') as $file) {
352-
$file = array_pop($file);
353-
354-
$doc = new \DOMDocument();
355-
$doc->load($file);
356-
foreach ($doc->getElementsByTagName('job') as $job) {
357-
/** @var \DOMElement $job */
358-
unset($methods[$job->getAttribute('method')]);
359-
}
360-
}
361-
return $methods;
362-
}
363250
}

lib/internal/Magento/Framework/App/Response/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function representJson($content)
156156
*/
157157
public function __sleep()
158158
{
159-
return ['content', 'isRedirect', 'statusCode', 'context'];
159+
return ['content', 'isRedirect', 'statusCode', 'context', 'headers'];
160160
}
161161

162162
/**

lib/internal/Magento/Framework/Composer/ComposerInformation.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class ComposerInformation
4444
*/
4545
const COMPONENT_PACKAGE_TYPE = 'magento2-component';
4646

47+
/**
48+
* Default composer repository key
49+
*/
50+
const COMPOSER_DEFAULT_REPO_KEY = 'packagist';
51+
4752
/**#@+
4853
* Composer command
4954
*/
@@ -286,4 +291,22 @@ public function getPackageRequirements($name, $version)
286291
$package = $this->composer->getRepositoryManager()->findPackage($name, $version);
287292
return $package->getRequires();
288293
}
294+
295+
/**
296+
* Returns all repository URLs, except local and packagists.
297+
*
298+
* @return string[]
299+
*/
300+
public function getRootRepositories()
301+
{
302+
$repositoryUrls = [];
303+
304+
foreach ($this->composer->getConfig()->getRepositories() as $key => $repository) {
305+
if ($key !== self::COMPOSER_DEFAULT_REPO_KEY) {
306+
$repositoryUrls[] = $repository['url'];
307+
}
308+
}
309+
310+
return $repositoryUrls;
311+
}
289312
}

lib/internal/Magento/Framework/Console/GenerationDirectoryAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function check()
5757
try {
5858
$probeFilePath = $generationDirectoryPath . DIRECTORY_SEPARATOR . time();
5959
$fileWriteFactory->create($probeFilePath, DriverPool::FILE, 'w');
60-
$directoryWrite->delete($probeFilePath);
60+
$driver->deleteFile($probeFilePath);
6161
} catch (\Exception $e) {
6262
return false;
6363
}

lib/internal/Magento/Framework/ObjectManager/ObjectManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ObjectManager implements \Magento\Framework\ObjectManagerInterface
2727
protected $_sharedInstances = [];
2828

2929
/**
30-
* @var Config\Config
30+
* @var ConfigInterface
3131
*/
3232
protected $_config;
3333

setup/src/Magento/Setup/Console/Command/DiCompileCommand.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ private function checkEnvironment()
111111
$messages[] = 'You cannot run this command because the Magento application is not installed.';
112112
}
113113

114-
/**
115-
* By the time the command is able to execute, the Object Management configuration is already contaminated
116-
* by old config info, and it's too late to just clear the files in code.
117-
*
118-
* TODO: reconfigure OM in runtime so DI resources can be cleared after command launches
119-
*
120-
*/
121-
$path = $this->directoryList->getPath(DirectoryList::DI);
122-
if ($this->fileDriver->isExists($path)) {
123-
$messages[] = "DI configuration must be cleared before running compiler. Please delete '$path'.";
124-
}
125-
126114
return $messages;
127115
}
128116

0 commit comments

Comments
 (0)