/** * Apply config filters * * @param RequestCollection $passwordResetRequestEventCollection * @param int $securityEventType * @param string $accountReference * @param int $longIp * @return RequestCollection */ protected function applyFiltersByConfig(RequestCollection $passwordResetRequestEventCollection, $securityEventType, $accountReference, $longIp) { $limitMethod = $this->securityConfig->getLimitPasswordResetRequestsMethod($this->getScopeByEventType($securityEventType)); switch ($limitMethod) { case ResetMethod::OPTION_BY_EMAIL: $passwordResetRequestEventCollection->filterByAccountReference($accountReference); break; case ResetMethod::OPTION_BY_IP: $passwordResetRequestEventCollection->filterByIp($longIp); break; case ResetMethod::OPTION_BY_IP_AND_EMAIL: $passwordResetRequestEventCollection->filterByIpOrAccountReference($longIp, $accountReference); break; } return $passwordResetRequestEventCollection; }
/** * @param int $resetMethod * @param int $scope * @dataProvider dataProviderResetMethodValues */ public function testGetLimitPasswordResetRequestsMethod($resetMethod, $scope) { $this->scopeConfigMock->expects($this->once())->method('getValue')->with($this->getXmlPathByScope($scope) . \Magento\Security\Helper\SecurityConfig::XML_PATH_LIMIT_PASSWORD_RESET_REQUESTS_METHOD)->will($this->returnValue($resetMethod)); $this->assertEquals($resetMethod, $this->helper->getLimitPasswordResetRequestsMethod($scope)); }