/** * Delete Expired Captcha Images for specific website * * @param \Magento\Captcha\Helper\Data $helper * @param \Magento\Store\Model\Website|null $website * @param \Magento\Store\Model\Store|null $store * @return void */ protected function _deleteExpiredImagesForWebsite(\Magento\Captcha\Helper\Data $helper, \Magento\Store\Model\Website $website = null, \Magento\Store\Model\Store $store = null) { $expire = time() - $helper->getConfig('timeout', $store) * 60; $imageDirectory = $this->_mediaDirectory->getRelativePath($helper->getImgDir($website)); foreach ($this->_mediaDirectory->read($imageDirectory) as $filePath) { if ($this->_mediaDirectory->isFile($filePath) && pathinfo($filePath, PATHINFO_EXTENSION) == 'png' && $this->_mediaDirectory->stat($filePath)['mtime'] < $expire) { $this->_mediaDirectory->delete($filePath); } } }
/** * Retrieve list of forms where captcha must be shown * * For frontend this list is based on current website * * @return array */ protected function _getTargetForms() { $formsString = (string) $this->_captchaData->getConfig('forms'); return explode(',', $formsString); }
/** * @covers \Magento\Captcha\Helper\Data::getConfig */ public function testGetConfigNode() { $this->configMock->expects($this->once())->method('getValue')->with('customer/captcha/enable', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue('1')); $this->helper->getConfig('enable'); }