Skip to content

Commit

Permalink
Merge pull request #1819 from magento-engcom/2.2-develop-prs
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests - 2.2-develop
 - MAGETWO-85311: Added namespace to product videos fotorama events #12469 #991
 - MAGETWO-85300: 8437: Silent error when an email template is not found #970
 - MAGETWO-85293: 12613: Verbiage Update Required: Product Image Watermark size Validation Message. #985
 - MAGETWO-85286: 8176: LinkManagement::getChildren() does not include product visibility. #986
 - MAGETWO-85285: 12482: Sitemap image links in MultiStore #935
 - MAGETWO-84955: Set Current Store from Store Code if isUseStoreInUrl #12529
 - MAGETWO-84764: NewRelic: Disables Module Deployments, Creates new Deploy Marker Command #12477
 - MAGETWO-84439: 12180 Remove unnecessary use operator for Context, causes 503 error i… #12220
  • Loading branch information
ishakhsuvarov authored Dec 11, 2017
2 parents d865ef1 + 35b278d commit 35f404b
Show file tree
Hide file tree
Showing 20 changed files with 282 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ Submit,Submit
"We don't recognize or support this file extension type.","We don't recognize or support this file extension type."
"Configure Product","Configure Product"
OK,OK
"This value does not follow the specified format (for example, 200X300).","This value does not follow the specified format (for example, 200X300)."
"This value does not follow the specified format (for example, 200x300).","This value does not follow the specified format (for example, 200x300)."
"Select type of option.","Select type of option."
"Please add rows to option.","Please add rows to option."
"Please select items.","Please select items."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ define([

return !!(m && m[1] > 0 && m[2] > 0);
},
$.mage.__('This value does not follow the specified format (for example, 200X300).')
$.mage.__('This value does not follow the specified format (for example, 200x300).')
);

return Abstract.extend({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\ConfigurableProduct\Model\Product\Type;

use Magento\Catalog\Api\Data\ProductAttributeInterface;
Expand Down Expand Up @@ -682,7 +683,7 @@ private function saveConfigurableOptions(ProductInterface $product)
->setProductId($product->getData($metadata->getLinkField()))
->save();
}
/** @var $configurableAttributesCollection \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection */
/** @var $configurableAttributesCollection \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection */
$configurableAttributesCollection = $this->_attributeCollectionFactory->create();
$configurableAttributesCollection->setProductFilter($product);
$configurableAttributesCollection->addFieldToFilter(
Expand Down Expand Up @@ -1397,7 +1398,16 @@ private function getConfiguredUsedProductCollection(\Magento\Catalog\Model\Produ
->addFilterByRequiredOptions()
->setStoreId($product->getStoreId());

$requiredAttributes = ['name', 'price', 'weight', 'image', 'thumbnail', 'status', 'media_gallery'];
$requiredAttributes = [
'name',
'price',
'weight',
'image',
'thumbnail',
'status',
'visibility',
'media_gallery'
];
foreach ($requiredAttributes as $attributeCode) {
$collection->addAttributeToSelect($attributeCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$this->productFactory = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterfaceFactory::class)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();

$this->salableProcessor = $this->createMock(SalableProcessor::class);

$this->model = $this->objectHelper->getObject(
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ protected function sendEmailConfirmation(CustomerInterface $customer, $redirectU
} catch (MailException $e) {
// If we are not able to send a new account email, this should be ignored
$this->logger->critical($e);
} catch (\UnexpectedValueException $e) {
$this->logger->error($e);
}
}

Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Customer/Model/AttributeChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Magento\Customer\Api\AddressMetadataInterface;
use Magento\Customer\Api\AddressMetadataManagementInterface;
use Magento\Customer\Model\Metadata\AttributeResolver;
use Magento\Framework\App\Helper\Context;

/**
* Customer attribute checker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1721,4 +1721,102 @@ private function prepareDateTimeFactory()

return $dateTime;
}

public function testCreateAccountUnexpectedValueException()
{
$websiteId = 1;
$storeId = null;
$defaultStoreId = 1;
$customerId = 1;
$customerEmail = '[email protected]';
$newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu';
$exception = new \UnexpectedValueException('Template file was not found');

$datetime = $this->prepareDateTimeFactory();

$address = $this->createMock(\Magento\Customer\Api\Data\AddressInterface::class);
$address->expects($this->once())
->method('setCustomerId')
->with($customerId);
$store = $this->createMock(\Magento\Store\Model\Store::class);
$store->expects($this->once())
->method('getId')
->willReturn($defaultStoreId);
$website = $this->createMock(\Magento\Store\Model\Website::class);
$website->expects($this->atLeastOnce())
->method('getStoreIds')
->willReturn([1, 2, 3]);
$website->expects($this->once())
->method('getDefaultStore')
->willReturn($store);
$customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
$customer->expects($this->atLeastOnce())
->method('getId')
->willReturn($customerId);
$customer->expects($this->atLeastOnce())
->method('getEmail')
->willReturn($customerEmail);
$customer->expects($this->atLeastOnce())
->method('getWebsiteId')
->willReturn($websiteId);
$customer->expects($this->atLeastOnce())
->method('getStoreId')
->willReturn($storeId);
$customer->expects($this->once())
->method('setStoreId')
->with($defaultStoreId);
$customer->expects($this->once())
->method('getAddresses')
->willReturn([$address]);
$customer->expects($this->once())
->method('setAddresses')
->with(null);
$this->customerRepository->expects($this->once())
->method('get')
->with($customerEmail)
->willReturn($customer);
$this->share->expects($this->once())
->method('isWebsiteScope')
->willReturn(true);
$this->storeManager->expects($this->atLeastOnce())
->method('getWebsite')
->with($websiteId)
->willReturn($website);
$this->customerRepository->expects($this->atLeastOnce())
->method('save')
->willReturn($customer);
$this->addressRepository->expects($this->atLeastOnce())
->method('save')
->with($address);
$this->customerRepository->expects($this->once())
->method('getById')
->with($customerId)
->willReturn($customer);
$this->random->expects($this->once())
->method('getUniqueHash')
->willReturn($newLinkToken);
$customerSecure = $this->createPartialMock(
\Magento\Customer\Model\Data\CustomerSecure::class,
['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash']
);
$customerSecure->expects($this->any())
->method('setRpToken')
->with($newLinkToken);
$customerSecure->expects($this->any())
->method('setRpTokenCreatedAt')
->with($datetime)
->willReturnSelf();
$customerSecure->expects($this->any())
->method('getPasswordHash')
->willReturn(null);
$this->customerRegistry->expects($this->atLeastOnce())
->method('retrieveSecureData')
->willReturn($customerSecure);
$this->emailNotificationMock->expects($this->once())
->method('newAccount')
->willThrowException($exception);
$this->logger->expects($this->once())->method('error')->with($exception);

$this->accountManagement->createAccount($customer);
}
}
23 changes: 22 additions & 1 deletion app/code/Magento/Email/Model/Template/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,9 @@ public function getTemplateFilename($templateId, $designParams = [])
$designParams['module'] = $module;

$file = $this->_getInfo($templateId, 'file');
$filename = $this->getFilename($file, $designParams, $module);

return $this->viewFileSystem->getEmailTemplateFileName($file, $designParams, $module);
return $filename;
}

/**
Expand All @@ -230,4 +231,24 @@ protected function _getInfo($templateId, $fieldName)
}
return $data[$templateId][$fieldName];
}

/**
* @param string $file
* @param array $designParams
* @param string $module
*
* @return string
*
* @throws \UnexpectedValueException
*/
private function getFilename($file, array $designParams, $module)
{
$filename = $this->viewFileSystem->getEmailTemplateFileName($file, $designParams, $module);

if ($filename === false) {
throw new \UnexpectedValueException("Template file '{$file}' is not found.");
}

return $filename;
}
}
13 changes: 13 additions & 0 deletions app/code/Magento/Email/Test/Unit/Model/Template/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ public function testGetTemplateFilenameWithNoParams()
$this->assertEquals('_files/Fixture/ModuleOne/view/frontend/email/one.html', $actualResult);
}

/**
* @expectedException \UnexpectedValueException
* @expectedExceptionMessage Template file 'one.html' is not found
*/
public function testGetTemplateFilenameWrongFileName()
{
$this->viewFileSystem->expects($this->once())->method('getEmailTemplateFileName')
->with('one.html', $this->designParams, 'Fixture_ModuleOne')
->willReturn(false);

$this->model->getTemplateFilename('template_one', $this->designParams);
}

/**
* @param string $getterMethod
* @param $argument
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
'changelog',
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('changelog'),
$this->serviceShellUser->get($input->getArgument('user'))
);
$output->writeln('<info>NewRelic deployment information sent</info>');
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit 35f404b

Please sign in to comment.