This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,215 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Composer;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Tests Magento\Framework\ComposerInformation
*/
class ComposerInformationTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
private $objectManager;
/**
* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\App\Filesystem\DirectoryList
*/
private $directoryList;
/**
* @var ComposerJsonFinder
*/
private $composerJsonFinder;
/**
* @var ComposerFactory
*/
private $composerFactory;
/**
* @inheritDoc
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
}
/**
* Setup DirectoryList, Filesystem, and ComposerJsonFinder to use a specified directory for reading composer files
*
* @param $composerDir string Directory under _files that contains composer files
*/
private function setupDirectory($composerDir)
{
$directories = [
DirectoryList::CONFIG => [DirectoryList::PATH => __DIR__ . '/_files/'],
DirectoryList::ROOT => [DirectoryList::PATH => __DIR__ . '/_files/' . $composerDir],
DirectoryList::COMPOSER_HOME => [DirectoryList::PATH => __DIR__ . '/_files/' . $composerDir],
];
$this->directoryList = $this->objectManager->create(
\Magento\Framework\App\Filesystem\DirectoryList::class,
['root' => __DIR__ . '/_files/' . $composerDir, 'config' => $directories]
);
$this->composerJsonFinder = new ComposerJsonFinder($this->directoryList);
$this->composerFactory = new ComposerFactory($this->directoryList, $this->composerJsonFinder);
}
/**
* @param $composerDir string Directory under _files that contains composer files
*
* @dataProvider getRequiredPhpVersionDataProvider
*/
public function testGetRequiredPhpVersion($composerDir)
{
$this->setupDirectory($composerDir);
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
$this->assertEquals("~8.1.0", $composerInfo->getRequiredPhpVersion());
}
/**
* @param $composerDir string Directory under _files that contains composer files
*
* @dataProvider getRequiredPhpVersionDataProvider
*/
public function testGetRequiredExtensions($composerDir)
{
$this->setupDirectory($composerDir);
$expectedExtensions = ['ctype', 'gd', 'spl', 'dom', 'simplexml', 'hash', 'curl', 'iconv', 'intl'];
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
$actualRequiredExtensions = $composerInfo->getRequiredExtensions();
foreach ($expectedExtensions as $expectedExtension) {
$this->assertContains($expectedExtension, $actualRequiredExtensions);
}
}
/**
* @param $composerDir string Directory under _files that contains composer files
*
* @dataProvider getRequiredPhpVersionDataProvider
*/
public function testGetSuggestedPackages($composerDir)
{
$this->setupDirectory($composerDir);
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
$actualSuggestedExtensions = $composerInfo->getSuggestedPackages();
$this->assertArrayHasKey('psr/log', $actualSuggestedExtensions);
}
/**
* @param $composerDir string Directory under _files that contains composer files
*
* @dataProvider getRequiredPhpVersionDataProvider
*/
public function testGetRootRequiredPackagesAndTypes($composerDir)
{
$this->setupDirectory($composerDir);
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
$requiredPackagesAndTypes = $composerInfo->getRootRequiredPackageTypesByName();
$this->assertArrayHasKey('composer/composer', $requiredPackagesAndTypes);
$this->assertEquals('library', $requiredPackagesAndTypes['composer/composer']);
}
/**
* Data provider that returns directories containing different types of composer files.
*
* @return array
*/
public function getRequiredPhpVersionDataProvider()
{
return [
'Skeleton Composer' => ['testSkeleton'],
'Composer.json from git clone' => ['testFromClone'],
'Composer.json from git create project' => ['testFromCreateProject'],
];
}
public function testIsPackageInComposerJson()
{
$this->setupDirectory('testSkeleton');
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
$packageName = 'magento/sample-module-minimal';
$this->assertTrue($composerInfo->isPackageInComposerJson($packageName));
$packageName = 'magento/wrong-module-name';
$this->assertFalse($composerInfo->isPackageInComposerJson($packageName));
}
/**
* @param $composerDir string Directory under _files that contains composer files
*
* @dataProvider getRequiredPhpVersionDataProvider
*/
public function testGetRootRepositories($composerDir)
{
$this->setupDirectory($composerDir);
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
if ($composerDir === 'testFromCreateProject') {
$this->assertEquals(['https://repo.magento.com/'], $composerInfo->getRootRepositories());
} else {
$this->assertEquals([], $composerInfo->getRootRepositories());
}
}
/**
* @param $composerDir string Directory under _files that contains composer files
*
* @dataProvider getRequiredPhpVersionDataProvider
*/
public function testIsMagentoRoot($composerDir)
{
$this->setupDirectory($composerDir);
/** @var \Magento\Framework\Composer\ComposerInformation $composerInfo */
$composerInfo = $this->objectManager->create(
\Magento\Framework\Composer\ComposerInformation::class,
['composerFactory' => $this->composerFactory]
);
if ($composerDir === 'testFromClone') {
$this->assertTrue($composerInfo->isMagentoRoot());
} else {
$this->assertFalse($composerInfo->isMagentoRoot());
}
}
}
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Composer;
use Magento\Composer\MagentoComposerApplication;
class RemoveTest extends \PHPUnit\Framework\TestCase
{
public function testRemove()
{
$composerAppFactory = $this->getMockBuilder(MagentoComposerApplicationFactory::class)
->disableOriginalConstructor()
->getMock();
$composerApp = $this->getMockBuilder(MagentoComposerApplication::class)
->disableOriginalConstructor()
->getMock();
$composerApp->expects($this->once())
->method('runComposerCommand')
->with(
[
'command' => 'remove',
'packages' => ['magento/package-a', 'magento/package-b'],
'--no-update-with-dependencies' => true,
]
);
$composerAppFactory->expects($this->once())
->method('create')
->willReturn($composerApp);
$remove = new Remove($composerAppFactory);
$remove->remove(['magento/package-a', 'magento/package-b']);
}
}
@@ -0,0 +1,7 @@
<IfVersion < 2.4>
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
@@ -0,0 +1,7 @@
<IfVersion < 2.4>
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
@@ -0,0 +1,211 @@
{
"name": "magento/magento2ce",
"description": "Magento 2 (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~8.1.0",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
"ext-gd": "*",
"ext-hash": "*",
"ext-iconv": "*",
"ext-intl": "*",
"ext-mcrypt": "*",
"ext-simplexml": "*",
"lib-libxml": "*",
"composer/composer": "1.0.0-alpha9",
"magento/magento-composer-installer": "*",
"magento/zendframework1": "*",
"monolog/monolog": "1.11.0",
"oyejorge/less.php": "1.7.0.3",
"phpseclib/phpseclib": "~0.3",
"symfony/console": "~2.3",
"tubalmartin/cssmin": "2.4.8-p6",
"laminas/laminas-code": "2.4.0",
"laminas/laminas-config": "2.4.0",
"laminas/laminas-console": "2.4.0",
"laminas/laminas-di": "2.4.0",
"laminas/laminas-eventmanager": "2.4.0",
"laminas/laminas-form": "2.4.0",
"laminas/laminas-http": "2.4.0",
"laminas/laminas-i18n": "2.4.0",
"laminas/laminas-json": "2.4.0",
"laminas/laminas-log": "2.4.0",
"laminas/laminas-modulemanager": "2.4.0",
"laminas/laminas-mvc": "2.4.0",
"laminas/laminas-serializer": "2.4.0",
"laminas/laminas-server": "2.4.0",
"laminas/laminas-servicemanager": "2.4.0",
"laminas/laminas-soap": "2.4.0",
"laminas/laminas-stdlib": "2.4.0",
"laminas/laminas-text": "2.4.0",
"laminas/laminas-uri": "2.4.0",
"laminas/laminas-validator": "2.4.0",
"laminas/laminas-view": "2.4.0"
},
"require-dev": {
"fabpot/php-cs-fixer": "~1.2",
"lusitanian/oauth": "~0.3",
"pdepend/pdepend": "2.0.6",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "4.1.0",
"sjparkinson/static-review": "~4.1",
"squizlabs/php_codesniffer": "1.5.3"
},
"replace": {
"magento/module-admin-notification": "*",
"magento/module-authorization": "*",
"magento/module-backend": "*",
"magento/module-backup": "*",
"magento/module-bundle": "*",
"magento/module-cache-invalidate": "*",
"magento/module-captcha": "*",
"magento/module-catalog": "*",
"magento/module-catalog-import-export": "*",
"magento/module-catalog-inventory": "*",
"magento/module-catalog-rule": "*",
"magento/module-catalog-search": "*",
"magento/module-catalog-url-rewrite": "*",
"magento/module-catalog-widget": "*",
"magento/module-centinel": "*",
"magento/module-checkout": "*",
"magento/module-checkout-agreements": "*",
"magento/module-cms": "*",
"magento/module-cms-url-rewrite": "*",
"magento/module-config": "*",
"magento/module-configurable-import-export": "*",
"magento/module-configurable-product": "*",
"magento/module-contact": "*",
"magento/module-cookie": "*",
"magento/module-cron": "*",
"magento/module-currency-symbol": "*",
"magento/module-customer": "*",
"magento/module-customer-import-export": "*",
"magento/module-developer": "*",
"magento/module-dhl": "*",
"magento/module-directory": "*",
"magento/module-downloadable": "*",
"magento/module-eav": "*",
"magento/module-email": "*",
"magento/module-fedex": "*",
"magento/module-gift-message": "*",
"magento/module-google-adwords": "*",
"magento/module-google-analytics": "*",
"magento/module-google-optimizer": "*",
"magento/module-grouped-import-export": "*",
"magento/module-grouped-product": "*",
"magento/module-import-export": "*",
"magento/module-indexer": "*",
"magento/module-integration": "*",
"magento/module-layered-navigation": "*",
"magento/module-media-storage": "*",
"magento/module-msrp": "*",
"magento/module-multishipping": "*",
"magento/module-newsletter": "*",
"magento/module-offline-payments": "*",
"magento/module-offline-shipping": "*",
"magento/module-page-cache": "*",
"magento/module-payment": "*",
"magento/module-persistent": "*",
"magento/module-product-alert": "*",
"magento/module-quote": "*",
"magento/module-reports": "*",
"magento/module-require-js": "*",
"magento/module-review": "*",
"magento/module-rss": "*",
"magento/module-rule": "*",
"magento/module-sales": "*",
"magento/module-sales-rule": "*",
"magento/module-sales-sequence": "*",
"magento/module-search": "*",
"magento/module-sendfriend": "*",
"magento/module-shipping": "*",
"magento/module-sitemap": "*",
"magento/module-store": "*",
"magento/module-tax": "*",
"magento/module-tax-import-export": "*",
"magento/module-theme": "*",
"magento/module-translation": "*",
"magento/module-ui": "*",
"magento/module-ups": "*",
"magento/module-url-rewrite": "*",
"magento/module-user": "*",
"magento/module-usps": "*",
"magento/module-variable": "*",
"magento/module-version": "*",
"magento/module-webapi": "*",
"magento/module-weee": "*",
"magento/module-widget": "*",
"magento/module-wishlist": "*",
"magento/theme-adminhtml-backend": "*",
"magento/theme-frontend-blank": "*",
"magento/theme-frontend-luma": "*",
"magento/language-de_de": "*",
"magento/language-en_us": "*",
"magento/language-es_es": "*",
"magento/language-fr_fr": "*",
"magento/language-nl_nl": "*",
"magento/language-pt_br": "*",
"magento/language-zh_cn": "*",
"magento/framework": "*",
"trentrichardson/jquery-timepicker-addon": "1.4.3",
"colinmollenhour/cache-backend-redis": "dev-master#193d377b7fb2e88595578b282fa01a62d1185abc",
"colinmollenhour/credis": "dev-master#f07bbfd4117294f462f0fb19c49221d350bf396f",
"linkorb/jsmin-php": "1.1.2",
"components/jquery": "1.11.0",
"blueimp/jquery-file-upload": "5.6.14",
"components/jqueryui": "1.10.4",
"twbs/bootstrap": "3.1.0",
"tinymce/tinymce": "3.4.7"
},
"extra": {
"component_paths": {
"trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
"colinmollenhour/cache-backend-redis": "lib/internal/Cm/Cache/Backend/Redis.php",
"colinmollenhour/credis": "lib/internal/Credis",
"linkorb/jsmin-php": "lib/internal/JSMin",
"components/jquery": [
"lib/web/jquery.js",
"lib/web/jquery/jquery.min.js"
],
"blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
"components/jqueryui": [
"lib/web/jquery/jquery-ui.js",
"lib/web/jquery/jquery-ui.min.js"
],
"twbs/bootstrap": [
"lib/web/jquery/jquery.tabs.js"
],
"tinymce/tinymce": "lib/web/tiny_mce"
}
},
"config": {
"allow-plugins": {
"magento/*": true
},
"sort-packages": true,
"use-include-path": true
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/"
}
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
}
},
"minimum-stability": "alpha",
"prefer-stable": true
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
This file is to create a vendor directory for testing
@@ -0,0 +1,7 @@
<IfVersion < 2.4>
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
@@ -0,0 +1,7 @@
<IfVersion < 2.4>
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
@@ -0,0 +1,49 @@
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/product-community-edition": "*"
},
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
"require-dev": {
"fabpot/php-cs-fixer": "~1.2",
"lusitanian/oauth": "~0.3",
"pdepend/pdepend": "2.0.6",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "4.1.0",
"sjparkinson/static-review": "~4.1",
"squizlabs/php_codesniffer": "1.5.3"
},
"config": {
"sort-packages": true,
"use-include-path": true
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/"
}
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
"Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/"
}
},
"minimum-stability": "alpha",
"prefer-stable": true
}
@@ -0,0 +1,5 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
This file is to create a vendor directory for testing
@@ -0,0 +1,7 @@
<IfVersion < 2.4>
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
@@ -0,0 +1,7 @@
<IfVersion < 2.4>
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
@@ -0,0 +1,20 @@
{
"config": {
"sort-packages": true
},
"require": {
"magento/product-community-edition": "*",
"magento/sample-module-minimal" : "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "htdocs/lib/internal/Magento/Framework/",
"Magento\\Setup\\": "htdocs/setup/src/Magento/Setup/"
}
},
"extra": {
"magento-root-dir": "htdocs",
"magento-deploystrategy": "copy"
},
"minimum-stability": "dev"
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
This file is to create a vendor directory for testing
@@ -0,0 +1,10 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Path to Composer vendor directory
*/
return './vendor';