Skip to content

Commit 019747b

Browse files
author
Stanislav Idolov
committed
magento-commerce/magento2ce#7192: Fixed static tests failures
1 parent 21d8790 commit 019747b

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class DefaultStock extends AbstractIndexer implements StockInterface
7979
* @param StrategyInterface $tableStrategy
8080
* @param Config $eavConfig
8181
* @param ScopeConfigInterface $scopeConfig
82-
* @param null $connectionName
82+
* @param string $connectionName
8383
* @param GetStatusExpression|null $getStatusExpression
8484
* @param StockConfigurationInterface|null $stockConfiguration
8585
* @param QueryProcessorComposite|null $queryProcessorComposite

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ class AccountManagement implements AccountManagementInterface
424424
* @param AllowedCountries|null $allowedCountriesReader
425425
* @param SessionCleanerInterface|null $sessionCleaner
426426
* @param AuthorizationInterface|null $authorization
427+
* @param AuthenticationInterface|null $authentication
428+
* @param Backend|null $eavValidator
427429
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
428430
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
429431
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -465,7 +467,9 @@ public function __construct(
465467
GetCustomerByToken $getByToken = null,
466468
AllowedCountries $allowedCountriesReader = null,
467469
SessionCleanerInterface $sessionCleaner = null,
468-
AuthorizationInterface $authorization = null
470+
AuthorizationInterface $authorization = null,
471+
AuthenticationInterface $authentication = null,
472+
Backend $eavValidator = null
469473
) {
470474
$this->customerFactory = $customerFactory;
471475
$this->eventManager = $eventManager;
@@ -506,22 +510,8 @@ public function __construct(
506510
?: $objectManager->get(AllowedCountries::class);
507511
$this->sessionCleaner = $sessionCleaner ?? $objectManager->get(SessionCleanerInterface::class);
508512
$this->authorization = $authorization ?? $objectManager->get(AuthorizationInterface::class);
509-
}
510-
511-
/**
512-
* Get authentication
513-
*
514-
* @return AuthenticationInterface
515-
*/
516-
private function getAuthentication()
517-
{
518-
if (!($this->authentication instanceof AuthenticationInterface)) {
519-
return \Magento\Framework\App\ObjectManager::getInstance()->get(
520-
\Magento\Customer\Model\AuthenticationInterface::class
521-
);
522-
} else {
523-
return $this->authentication;
524-
}
513+
$this->authentication = $authentication ?? $objectManager->get(AuthenticationInterface::class);
514+
$this->eavValidator = $eavValidator ?? $objectManager->get(Backend::class);
525515
}
526516

527517
/**
@@ -617,11 +607,11 @@ public function authenticate($username, $password)
617607
}
618608

619609
$customerId = $customer->getId();
620-
if ($this->getAuthentication()->isLocked($customerId)) {
610+
if ($this->authentication->isLocked($customerId)) {
621611
throw new UserLockedException(__('The account is locked.'));
622612
}
623613
try {
624-
$this->getAuthentication()->authenticate($customerId, $password);
614+
$this->authentication->authenticate($customerId, $password);
625615
} catch (InvalidEmailOrPasswordException $e) {
626616
throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
627617
}
@@ -1053,7 +1043,7 @@ public function changePasswordById($customerId, $currentPassword, $newPassword)
10531043
private function changePasswordForCustomer($customer, $currentPassword, $newPassword)
10541044
{
10551045
try {
1056-
$this->getAuthentication()->authenticate($customer->getId(), $currentPassword);
1046+
$this->authentication->authenticate($customer->getId(), $currentPassword);
10571047
} catch (InvalidEmailOrPasswordException $e) {
10581048
throw new InvalidEmailOrPasswordException(
10591049
__("The password doesn't match this account. Verify the password and try again.")
@@ -1084,19 +1074,6 @@ protected function createPasswordHash($password)
10841074
return $this->encryptor->getHash($password, true);
10851075
}
10861076

1087-
/**
1088-
* Get EAV validator
1089-
*
1090-
* @return Backend
1091-
*/
1092-
private function getEavValidator()
1093-
{
1094-
if ($this->eavValidator === null) {
1095-
$this->eavValidator = ObjectManager::getInstance()->get(Backend::class);
1096-
}
1097-
return $this->eavValidator;
1098-
}
1099-
11001077
/**
11011078
* @inheritdoc
11021079
*/
@@ -1110,13 +1087,13 @@ public function validate(CustomerInterface $customer)
11101087
);
11111088
$customer->setAddresses($oldAddresses);
11121089

1113-
$result = $this->getEavValidator()->isValid($customerModel);
1114-
if ($result === false && is_array($this->getEavValidator()->getMessages())) {
1090+
$result = $this->eavValidator->isValid($customerModel);
1091+
if ($result === false && is_array($this->eavValidator->getMessages())) {
11151092
return $validationResults->setIsValid(false)->setMessages(
11161093
// phpcs:ignore Magento2.Functions.DiscouragedFunction
11171094
call_user_func_array(
11181095
'array_merge',
1119-
array_values($this->getEavValidator()->getMessages())
1096+
array_values($this->eavValidator->getMessages())
11201097
)
11211098
);
11221099
}

0 commit comments

Comments
 (0)