Skip to content

Commit

Permalink
MAGETWO-87531: [EngCom Team] Batch 27. Forwardports to 2.3-develop #1342
Browse files Browse the repository at this point in the history


 - Merge Pull Request magento-engcom/magento2ce#1342 from magento-engcom-team/magento2:batch-27-forwardport-2.3-develop
 - Merged commits:
   1. aa93f83
   2. 0b76fcd
   3. be77fdd
   4. 4bad8be
   5. 59e1020
   6. ef63b3a
   7. a278aaf
   8. f7c00d7
   9. f1ecb11
   10. 74aabb4
   11. 1d66e5e
   12. dc4977d
   13. 99f982c
   14. 76c4f0d
   15. 9e2cc5e
   16. 82d488b
  • Loading branch information
ishakhsuvarov committed Feb 8, 2018
2 parents ec39184 + 82d488b commit 8007239
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 67 deletions.
2 changes: 1 addition & 1 deletion COPYING.txt
@@ -1,4 +1,4 @@
Copyright © 2013-2017 Magento, Inc.
Copyright © 2013-2018 Magento, Inc.

Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license

Expand Down
Expand Up @@ -146,8 +146,8 @@ switch ($type = $block->getType()) {
}
break;

case 'other':
break;
default:
$exist = null;
}
?>

Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
Expand Down
@@ -0,0 +1,81 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\NewRelicReporting\Console\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Magento\NewRelicReporting\Model\Apm\DeploymentsFactory;
use Magento\NewRelicReporting\Model\ServiceShellUser;

class DeployMarker extends Command
{
/**
* @var DeploymentsFactory
*/
private $deploymentsFactory;

/**
* @var ServiceShellUser
*/
private $serviceShellUser;

/**
* Initialize dependencies.
*
* @param DeploymentsFactory $deploymentsFactory
* @param ServiceShellUser $serviceShellUser
* @param null $name
*/
public function __construct(
DeploymentsFactory $deploymentsFactory,
ServiceShellUser $serviceShellUser,
$name = null
) {
$this->deploymentsFactory = $deploymentsFactory;
$this->serviceShellUser = $serviceShellUser;
parent::__construct($name);
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this->setName("newrelic:create:deploy-marker");
$this->setDescription("Check the deploy queue for entries and create an appropriate deploy marker.")
->addArgument(
'message',
InputArgument::REQUIRED,
'Deploy Message?'
)
->addArgument(
'change_log',
InputArgument::REQUIRED,
'Change Log?'
)
->addArgument(
'user',
InputArgument::OPTIONAL,
'Deployment User'
);
parent::configure();
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->deploymentsFactory->create()->setDeployment(
$input->getArgument('message'),
$input->getArgument('change_log'),
$this->serviceShellUser->get($input->getArgument('user'))
);
$output->writeln('<info>NewRelic deployment information sent</info>');
}
}
Expand Up @@ -175,7 +175,6 @@ protected function reportCounts()
public function report()
{
if ($this->config->isNewRelicEnabled()) {
$this->reportModules();
$this->reportCounts();
}

Expand Down
34 changes: 34 additions & 0 deletions app/code/Magento/NewRelicReporting/Model/ServiceShellUser.php
@@ -0,0 +1,34 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\NewRelicReporting\Model;

class ServiceShellUser
{
/**
* Default user name;
*/
const DEFAULT_USER = 'cron';

/**
* Get use name.
*
* @param bool $userFromArgument
* @return string
*/
public function get($userFromArgument = false)
{
if ($userFromArgument) {
return $userFromArgument;
}

$user = "echo \$USER";
if ($user) {
return $user;
}

return self::DEFAULT_USER;
}
}
Expand Up @@ -144,24 +144,10 @@ public function testReportNewRelicCronModuleDisabledFromConfig()
*/
public function testReportNewRelicCron()
{
$testModuleData = [
'changes' => [
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'enabled'],
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'disabled'],
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'installed'],
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'uninstalled'],
],
'enabled' => 1,
'disabled' => 1,
'installed' => 1,
];

$this->config->expects($this->once())
->method('isNewRelicEnabled')
->willReturn(true);
$this->collect->expects($this->once())
->method('getModuleData')
->willReturn($testModuleData);
$this->counter->expects($this->once())
->method('getAllProductsCount');
$this->counter->expects($this->once())
Expand Down Expand Up @@ -198,24 +184,10 @@ public function testReportNewRelicCron()
*/
public function testReportNewRelicCronRequestFailed()
{
$testModuleData = [
'changes' => [
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'enabled'],
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'disabled'],
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'installed'],
['name' => 'name', 'setup_version' => '2.0.0', 'type' => 'uninstalled'],
],
'enabled' => 1,
'disabled' => 1,
'installed' => 1,
];

$this->config->expects($this->once())
->method('isNewRelicEnabled')
->willReturn(true);
$this->collect->expects($this->once())
->method('getModuleData')
->willReturn($testModuleData);
$this->counter->expects($this->once())
->method('getAllProductsCount');
$this->counter->expects($this->once())
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/NewRelicReporting/etc/di.xml
Expand Up @@ -30,4 +30,11 @@
<type name="Magento\Framework\App\Http">
<plugin name="framework-http-newrelic" type="Magento\NewRelicReporting\Plugin\HttpPlugin"/>
</type>
<type name="Magento\Framework\Console\CommandListInterface">
<arguments>
<argument name="commands" xsi:type="array">
<item name="newrelicreporting_deploy_marker" xsi:type="object">Magento\NewRelicReporting\Console\Command\DeployMarker</item>
</argument>
</arguments>
</type>
</config>
Expand Up @@ -19,22 +19,32 @@ class ValidationMessage

/**
* @var \Magento\Framework\Locale\CurrencyInterface
* @deprecated since 101.0.0
*/
private $currency;

/**
* @var \Magento\Framework\Pricing\Helper\Data
*/
private $priceHelper;

/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Locale\CurrencyInterface $currency
* @param \Magento\Framework\Pricing\Helper\Data $priceHelper
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Locale\CurrencyInterface $currency
\Magento\Framework\Locale\CurrencyInterface $currency,
\Magento\Framework\Pricing\Helper\Data $priceHelper = null
) {
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->currency = $currency;
$this->priceHelper = $priceHelper ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Pricing\Helper\Data::class);
}

/**
Expand All @@ -50,13 +60,11 @@ public function getMessage()
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
if (!$message) {
$currencyCode = $this->storeManager->getStore()->getCurrentCurrencyCode();
$minimumAmount = $this->currency->getCurrency($currencyCode)->toCurrency(
$this->scopeConfig->getValue(
'sales/minimum_order/amount',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
);
$minimumAmount = $this->priceHelper->currency($this->scopeConfig->getValue(
'sales/minimum_order/amount',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
), true, false);

$message = __('Minimum order amount is %1', $minimumAmount);
} else {
//Added in order to address the issue: https://github.com/magento/magento2/issues/8287
Expand Down
Expand Up @@ -26,28 +26,34 @@ class ValidationMessageTest extends \PHPUnit\Framework\TestCase

/**
* @var \PHPUnit_Framework_MockObject_MockObject
* @deprecated since 101.0.0
*/
private $currencyMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $priceHelperMock;

protected function setUp()
{
$this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
$this->currencyMock = $this->createMock(\Magento\Framework\Locale\CurrencyInterface::class);
$this->priceHelperMock = $this->createMock(\Magento\Framework\Pricing\Helper\Data::class);

$this->model = new \Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage(
$this->scopeConfigMock,
$this->storeManagerMock,
$this->currencyMock
$this->currencyMock,
$this->priceHelperMock
);
}

public function testGetMessage()
{
$minimumAmount = 20;
$minimumAmountCurrency = '$20';
$currencyCode = 'currency_code';

$this->scopeConfigMock->expects($this->at(0))
->method('getValue')
->with('sales/minimum_order/description', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
Expand All @@ -58,27 +64,13 @@ public function testGetMessage()
->with('sales/minimum_order/amount', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
->willReturn($minimumAmount);

$storeMock = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getCurrentCurrencyCode']);
$storeMock->expects($this->once())->method('getCurrentCurrencyCode')->willReturn($currencyCode);
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
$this->priceHelperMock->expects($this->once())
->method('currency')
->with($minimumAmount, true, false)
->will($this->returnValue($minimumAmountCurrency));

$currencyMock = $this->createMock(\Magento\Framework\Currency::class);
$this->currencyMock->expects($this->once())
->method('getCurrency')
->with($currencyCode)
->willReturn($currencyMock);

$currencyMock->expects($this->once())
->method('toCurrency')
->with($minimumAmount)
->willReturn($minimumAmountCurrency);

$this->assertEquals(
__('Minimum order amount is %1', $minimumAmountCurrency),
$this->model->getMessage()
);
$this->assertEquals(__('Minimum order amount is %1', $minimumAmountCurrency), $this->model->getMessage());
}

public function testGetConfigMessage()
{
$configMessage = 'config_message';
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Sales/Model/Order/CustomerManagement.php
Expand Up @@ -131,6 +131,7 @@ public function create($orderId)
$customer = $this->customerFactory->create(['data' => $customerData]);
$account = $this->accountManagement->createAccount($customer);
$order->setCustomerId($account->getId());
$order->setCustomerIsGuest(0);
$this->orderRepository->save($order);

return $account;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Theme/etc/config.xml
Expand Up @@ -45,7 +45,7 @@ Disallow: /*SID=
<welcome>Default welcome msg!</welcome>
</header>
<footer translate="copyright">
<copyright>Copyright &#169; 2013-2017 Magento, Inc. All rights reserved.</copyright>
<copyright>Copyright &#169; 2013-2018 Magento, Inc. All rights reserved.</copyright>
</footer>
</design>
<theme>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Theme/i18n/en_US.csv
Expand Up @@ -142,7 +142,7 @@ Empty,Empty
"1 column","1 column"
Configuration,Configuration
"Default welcome msg!","Default welcome msg!"
"Copyright © 2013-2017 Magento, Inc. All rights reserved.","Copyright © 2013-2017 Magento, Inc. All rights reserved."
"Copyright © 2013-2018 Magento, Inc. All rights reserved.","Copyright © 2013-2018 Magento, Inc. All rights reserved."
"Design Config Grid","Design Config Grid"
"Rebuild design config grid index","Rebuild design config grid index"
"Admin empty","Admin empty"
Expand Down
Expand Up @@ -67,7 +67,7 @@ private function getRequestParams()
'header_logo_height' => '',
'header_logo_alt' => '',
'header_welcome' => 'Default welcome msg!',
'footer_copyright' => 'Copyright © 2013-2017 Magento, Inc. All rights reserved.',
'footer_copyright' => 'Copyright © 2013-2018 Magento, Inc. All rights reserved.',
'footer_absolute_footer' => '',
'default_robots' => 'INDEX,FOLLOW',
'custom_instructions' => '',
Expand Down
6 changes: 6 additions & 0 deletions lib/web/mage/apply/main.js
Expand Up @@ -32,6 +32,12 @@ define([
} else if ($(el)[component]) {
$(el)[component](config);
}
}, function (error) {
if ('console' in window && typeof window.console.error === 'function') {
console.error(error);
}

return true;
});
}

Expand Down

0 comments on commit 8007239

Please sign in to comment.