-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1819 from magento-engcom/2.2-develop-prs
[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
Showing
20 changed files
with
282 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
app/code/Magento/NewRelicReporting/Console/Command/DeployMarker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/code/Magento/NewRelicReporting/Model/ServiceShellUser.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.