Skip to content

Commit

Permalink
Merge pull request #52 from magento-commerce/develop
Browse files Browse the repository at this point in the history
MCLOUD-8486: Release Cloud Tools
  • Loading branch information
BaDos authored Mar 1, 2022
2 parents 5a4d952 + 77a07d1 commit aaecf00
Show file tree
Hide file tree
Showing 53 changed files with 318 additions and 81 deletions.
26 changes: 26 additions & 0 deletions .github/.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"templateVersion": "0.1",
"product": {
"name": "Magento Cloud Patches",
"description": "The Magento Cloud Patches package is a set of patches, previously used within the ece-tools package to improve the integration of all Magento versions with Cloud environments and to deliver critical fixes quickly"
},
"contacts": {
"team": {
"name": "Magic Mountain",
"DL": "Grp-magento-cloud-all",
"slackChannel": "magic_mountain"
}
},
"ticketTracker": {
"functionalJiraQueue": {
"projectKey": "MCLOUD"
},
"securityJiraQueue": {
"projectKey": "MAGREQ",
"component": "Magento Cloud Engineering"
}
},
"staticScan": {
"enable": false
}
}
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento-cloud-patches",
"description": "Provides critical fixes for Magento 2 Enterprise Edition",
"type": "magento2-component",
"version": "1.0.14",
"version": "1.0.15",
"license": "OSL-3.0",
"repositories": {
"repo.magento.com": {
Expand All @@ -11,7 +11,7 @@
}
},
"require": {
"php": "^7.0",
"php": "^7.2 || ^8.0",
"ext-json": "*",
"composer/composer": "@stable",
"composer/semver": "@stable",
Expand All @@ -25,10 +25,14 @@
"magento/quality-patches": "^1.1.0"
},
"require-dev": {
"codeception/codeception": "^2.5.3",
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.2",
"codeception/module-db": "^1.0",
"codeception/module-phpbrowser": "^1.0",
"codeception/module-rest": "^1.2",
"consolidation/robo": "^1.2",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "^7.2",
"phpunit/phpunit": "^8.5 || ^9.5",
"squizlabs/php_codesniffer": "^3.0"
},
"bin": [
Expand Down
3 changes: 3 additions & 0 deletions patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@
"Incompatible PHP Method Fix": {
"2.3.7-p1": "AC-384__Fix_Incompatible_PHP_Method__2.3.7-p1_ce.patch",
"2.4.3": "AC-384__Fix_Incompatible_PHP_Method__2.4.3_ce.patch"
},
"Fixed currency displaying on product page": {
">=2.4.3 <2.4.4": "MCLOUD-8279__Fixed_currency_displaying_on_product_page__2.4.3.patch"
}
},
"magento/module-paypal": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
diff -Nuar a/vendor/magento/module-directory/Model/Currency.php b/vendor/magento/module-directory/Model/Currency.php
index 65b47d7535c..e1815b25619 100644
--- a/vendor/magento/module-directory/Model/Currency.php
+++ b/vendor/magento/module-directory/Model/Currency.php
@@ -13,6 +13,7 @@ use Magento\Framework\Locale\Currency as LocaleCurrency;
use Magento\Framework\Locale\ResolverInterface as LocalResolverInterface;
use Magento\Framework\NumberFormatterFactory;
use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Framework\Exception\LocalizedException;

/**
* Currency model
@@ -39,8 +40,6 @@ class Currency extends \Magento\Framework\Model\AbstractModel
protected $_filter;

/**
- * Currency Rates
- *
* @var array
*/
protected $_rates;
@@ -147,11 +146,14 @@ class Currency extends \Magento\Framework\Model\AbstractModel
$this->_localeCurrency = $localeCurrency;
$this->currencyConfig = $currencyConfig ?: ObjectManager::getInstance()->get(CurrencyConfig::class);
$this->localeResolver = $localeResolver ?: ObjectManager::getInstance()->get(LocalResolverInterface::class);
- $this->numberFormatterFactory = $numberFormatterFactory ?: ObjectManager::getInstance()->get(NumberFormatterFactory::class);
+ $this->numberFormatterFactory = $numberFormatterFactory ?:
+ ObjectManager::getInstance()->get(NumberFormatterFactory::class);
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
}

/**
+ * Initializing Currency Resource model
+ *
* @return void
*/
protected function _construct()
@@ -253,10 +255,10 @@ class Currency extends \Magento\Framework\Model\AbstractModel
/**
* Convert price to currency format
*
- * @param float $price
- * @param mixed $toCurrency
- * @return float
- * @throws \Exception
+ * @param float $price
+ * @param mixed $toCurrency
+ * @return float
+ * @throws LocalizedException
*/
public function convert($price, $toCurrency = null)
{
@@ -266,7 +268,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel
return (float)$price * (float)$rate;
}

- throw new \Exception(__(
+ throw new LocalizedException(__(
'Undefined rate from "%1-%2".',
$this->getCode(),
$this->getCurrencyCodeFromToCurrency($toCurrency)
@@ -274,7 +276,10 @@ class Currency extends \Magento\Framework\Model\AbstractModel
}

/**
+ * Return the currency code
+ *
* @param mixed $toCurrency
+ *
* @return string
* @throws \Magento\Framework\Exception\InputException
*/
@@ -348,8 +353,11 @@ class Currency extends \Magento\Framework\Model\AbstractModel
}

/**
+ * Return formatted currency
+ *
* @param float $price
* @param array $options
+ *
* @return string
*/
public function formatTxt($price, $options = [])
@@ -420,7 +428,8 @@ class Currency extends \Magento\Framework\Model\AbstractModel
$this->numberFormatter = $this->getNumberFormatter($options);

$formattedCurrency = $this->numberFormatter->formatCurrency(
- $price, $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
+ $price,
+ $this->getCode() ?? $this->numberFormatter->getTextAttribute(\NumberFormatter::CURRENCY_CODE)
);

if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
@@ -430,7 +439,7 @@ class Currency extends \Magento\Framework\Model\AbstractModel

if ((array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
&& $options[LocaleCurrency::CURRENCY_OPTION_DISPLAY] === \Magento\Framework\Currency::NO_SYMBOL)) {
- $formattedCurrency = str_replace(' ', '', $formattedCurrency);
+ $formattedCurrency = preg_replace(['/[^0-9.,۰٫]+/', '/ /'], '', $formattedCurrency);
}

return preg_replace('/^\s+|\s+$/u', '', $formattedCurrency);
@@ -444,7 +453,10 @@ class Currency extends \Magento\Framework\Model\AbstractModel
*/
private function getNumberFormatter(array $options): \Magento\Framework\NumberFormatter
{
- $key = 'currency_' . md5($this->localeResolver->getLocale() . $this->serializer->serialize($options));
+ $key = 'currency_' . hash(
+ 'sha256',
+ ($this->localeResolver->getLocale() . $this->serializer->serialize($options))
+ );
if (!isset($this->numberFormatterCache[$key])) {
$this->numberFormatter = $this->numberFormatterFactory->create(
['locale' => $this->localeResolver->getLocale(), 'style' => \NumberFormatter::CURRENCY]
@@ -467,7 +479,8 @@ class Currency extends \Magento\Framework\Model\AbstractModel
{
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_SYMBOL, $options)) {
$this->numberFormatter->setSymbol(
- \NumberFormatter::CURRENCY_SYMBOL, $options[LocaleCurrency::CURRENCY_OPTION_SYMBOL]
+ \NumberFormatter::CURRENCY_SYMBOL,
+ $options[LocaleCurrency::CURRENCY_OPTION_SYMBOL]
);
}
if (array_key_exists(LocaleCurrency::CURRENCY_OPTION_DISPLAY, $options)
@@ -490,6 +503,8 @@ class Currency extends \Magento\Framework\Model\AbstractModel
}

/**
+ * Return the price format to be displayed to user
+ *
* @return string
*/
public function getOutputFormat()
@@ -532,6 +547,8 @@ class Currency extends \Magento\Framework\Model\AbstractModel
}

/**
+ * Retrieve base config currency data by config path.
+ *
* @return array
*/
public function getConfigBaseCurrencies()
28 changes: 13 additions & 15 deletions src/Test/Functional/Acceptance/AbstractCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,26 @@ protected function prepareTemplate(\CliTester $I, string $templateVersion, strin
$I->createArtifactsDir();
$I->createArtifactCurrentTestedCode('patches', '1.0.99');
$I->addArtifactsRepoToComposer();
$I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99');

$I->addEceDockerGitRepoToComposer();
$I->addQualityPatchesGitRepoToComposer();
$I->addEceToolsGitRepoToComposer();
$I->addCloudComponentsGitRepoToComposer();
$I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99');
$I->addDependencyToComposer(
'magento/magento-cloud-docker',
$I->getDependencyVersion('magento/magento-cloud-docker')
);
$I->addDependencyToComposer(
'magento/quality-patches',
$I->getDependencyVersion('magento/quality-patches')
);

$I->addDependencyToComposer(
$dependencies = [
'magento/magento-cloud-docker',
'magento/magento-cloud-components',
$I->getDependencyVersion('magento/magento-cloud-components')
);
$I->addDependencyToComposer(
'magento/quality-patches',
'magento/ece-tools',
$I->getDependencyVersion('magento/ece-tools')
);
];

foreach ($dependencies as $dependency) {
$I->assertTrue(
$I->addDependencyToComposer($dependency, $I->getDependencyVersion($dependency)),
'Can not add dependency ' . $dependency
);
}

if ($this->edition === 'CE' || $magentoVersion) {
$version = $magentoVersion ?: $this->getVersionRangeForMagento($I);
Expand Down
1 change: 1 addition & 0 deletions src/Test/Functional/Acceptance/Acceptance73Cest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected function patchesDataProvider(): array
['templateVersion' => '2.3.6', 'magentoVersion' => '2.3.6-p1'],
['templateVersion' => '2.3.7', 'magentoVersion' => '2.3.7'],
['templateVersion' => '2.3.7', 'magentoVersion' => '2.3.7-p1'],
['templateVersion' => '2.3.7', 'magentoVersion' => '2.3.7-p2'],
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
];
}
Expand Down
38 changes: 38 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance74CeCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php74ce
*/
class Acceptance74CeCest extends Acceptance74Cest
{
/**
* @var string
*/
protected $edition = 'CE';

/**
* @return array
*/
protected function patchesDataProvider(): array
{
return [
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0-p1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p2'],
// Magento 2.4.3 CE does not work on the cloud
// ['templateVersion' => '2.4.3', 'magentoVersion' => '2.4.3'],
// ['templateVersion' => '2.4.3', 'magentoVersion' => '2.4.3-p1'],
];
}
}
32 changes: 32 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance74Cest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php74
*/
class Acceptance74Cest extends AcceptanceCest
{
/**
* @return array
*/
protected function patchesDataProvider(): array
{
return [
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0-p1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p2'],
['templateVersion' => '2.4.3', 'magentoVersion' => '2.4.3'],
['templateVersion' => '2.4.3', 'magentoVersion' => '2.4.3-p1'],
];
}
}
2 changes: 1 addition & 1 deletion src/Test/Functional/Acceptance/AcceptanceCeCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php74ce
* @group php81ce
*/
class AcceptanceCeCest extends AcceptanceCest
{
Expand Down
12 changes: 2 additions & 10 deletions src/Test/Functional/Acceptance/AcceptanceCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php74
* @group php81
*/
class AcceptanceCest extends AbstractCest
{
Expand Down Expand Up @@ -49,15 +49,7 @@ public function testPatches(\CliTester $I, \Codeception\Example $data): void
protected function patchesDataProvider(): array
{
return [
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0'],
['templateVersion' => '2.4.0', 'magentoVersion' => '2.4.0-p1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1'],
['templateVersion' => '2.4.1', 'magentoVersion' => '2.4.1-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p1'],
['templateVersion' => '2.4.2', 'magentoVersion' => '2.4.2-p2'],
['templateVersion' => '2.4.3', 'magentoVersion' => '2.4.3'],
['templateVersion' => 'master'],
['templateVersion' => '2.4.4'],
];
}
}
Loading

0 comments on commit aaecf00

Please sign in to comment.