Skip to content

Commit

Permalink
Merge branch 2.3-develop into ENGCOM-4774-magento-magento2-22321
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-engcom-team committed Apr 18, 2019
2 parents 7812576 + 729650d commit ea9faba
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 25 deletions.
9 changes: 7 additions & 2 deletions app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
* @param string $rpToken
* @throws ExpiredException
* @throws NoSuchEntityException
*
* @return CustomerInterface
* @throws LocalizedException
*/
Expand Down Expand Up @@ -703,7 +702,12 @@ public function resetPassword($email, $resetToken, $newPassword)
$customerSecure->setRpTokenCreatedAt(null);
$customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
$this->destroyCustomerSessions($customer->getId());
$this->sessionManager->destroy();
if ($this->sessionManager->isSessionExists()) {
//delete old session and move data to the new session
//use this instead of $this->sessionManager->regenerateId because last one doesn't delete old session
// phpcs:ignore Magento2.Functions.DiscouragedFunction
session_regenerate_id(true);
}
$this->customerRepository->save($customer);

return true;
Expand Down Expand Up @@ -1564,6 +1568,7 @@ private function getEmailNotification()

/**
* Destroy all active customer sessions by customer id (current session will not be destroyed).
*
* Customer sessions which should be deleted are collecting from the "customer_visitor" table considering
* configured session lifetime.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1238,8 +1238,7 @@ public function testInitiatePasswordResetEmailReminder()

$storeId = 1;

mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
$hash = hash('sha256', microtime() . random_int(PHP_INT_MIN, PHP_INT_MAX));

$this->emailNotificationMock->expects($this->once())
->method('passwordReminder')
Expand All @@ -1263,8 +1262,7 @@ public function testInitiatePasswordResetEmailReset()
$templateIdentifier = 'Template Identifier';
$sender = 'Sender';

mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
$hash = hash('sha256', microtime() . random_int(PHP_INT_MIN, PHP_INT_MAX));

$this->emailNotificationMock->expects($this->once())
->method('passwordResetConfirmation')
Expand All @@ -1288,8 +1286,7 @@ public function testInitiatePasswordResetNoTemplate()
$templateIdentifier = 'Template Identifier';
$sender = 'Sender';

mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
$hash = hash('sha256', microtime() . random_int(PHP_INT_MIN, PHP_INT_MAX));

$this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);

Expand Down Expand Up @@ -1610,7 +1607,7 @@ function ($string) {
$this->customerSecure->expects($this->once())->method('setRpTokenCreatedAt')->with(null);
$this->customerSecure->expects($this->any())->method('setPasswordHash')->willReturn(null);

$this->sessionManager->expects($this->atLeastOnce())->method('destroy');
$this->sessionManager->method('isSessionExists')->willReturn(false);
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
->disableOriginalConstructor()
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/NewRelicReporting/Model/Module/Collect.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Magento\NewRelicReporting\Model\Config;
use Magento\NewRelicReporting\Model\Module;

/**
* Class for collecting data for the report
*/
class Collect
{
/**
Expand Down Expand Up @@ -92,7 +95,6 @@ protected function getAllModules()
* @param string $active
* @param string $setupVersion
* @param string $state
*
* @return array
*/
protected function getNewModuleChanges($moduleName, $active, $setupVersion, $state)
Expand Down Expand Up @@ -277,9 +279,7 @@ public function getModuleData($refresh = true)
$changes = array_diff($module, $changeTest);
$changesCleanArray = $this->getCleanChangesArray($changes);

if (count($changesCleanArray) > 0 ||
($this->moduleManager->isOutputEnabled($changeTest['name']) &&
$module['setup_version'] != null)) {
if (!empty($changesCleanArray)) {
$data = [
'entity_id' => $changeTest['entity_id'],
'name' => $changeTest['name'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ public function testGetModuleDataWithoutRefresh()
->method('getNames')
->willReturn($enabledModulesMockArray);

$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will(
$this->returnValue(false)
);

$this->assertInternalType(
'array',
$this->model->getModuleData()
Expand Down Expand Up @@ -256,10 +252,6 @@ public function testGetModuleDataRefresh($data)
->method('getNames')
->willReturn($enabledModulesMockArray);

$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will(
$this->returnValue(true)
);

$this->assertInternalType(
'array',
$this->model->getModuleData()
Expand Down Expand Up @@ -350,10 +342,6 @@ public function testGetModuleDataRefreshOrStatement($data)
->method('getNames')
->willReturn($enabledModulesMockArray);

$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will(
$this->returnValue(true)
);

$this->assertInternalType(
'array',
$this->model->getModuleData()
Expand Down
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.
*/
namespace Magento\NewRelicReporting\Model\Module;

use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;

/***
* Class CollectTest
*/
class CollectTest extends TestCase
{
/**
* @var Collect
*/
private $collect;

/**
* @inheritDoc
*/
protected function setUp()
{
$this->collect = Bootstrap::getObjectManager()->create(Collect::class);
}

/**
* @return void
*/
public function testReport()
{
$this->collect->getModuleData();
$moduleData = $this->collect->getModuleData();
$this->assertEmpty($moduleData['changes']);
}
}

0 comments on commit ea9faba

Please sign in to comment.