54 $this->_helper = $this->createMock(\
Magento\Captcha\Helper\Data::class);
55 $this->_adminHelper = $this->createMock(\
Magento\Captcha\Helper\Adminhtml\Data::class);
56 $this->_filesystem = $this->createMock(\
Magento\Framework\Filesystem::class);
57 $this->_directory = $this->createMock(\
Magento\Framework\Filesystem\Directory\Write::class);
58 $this->_storeManager = $this->createMock(\
Magento\Store\Model\StoreManager::class);
60 $this->_filesystem->expects(
65 $this->returnValue($this->_directory)
68 $this->_deleteExpiredImages = new \Magento\Captcha\Cron\DeleteExpiredImages(
81 $this->_storeManager->expects(
89 $this->_helper->expects(
94 $this->equalTo(
'timeout'),
95 new \PHPUnit\Framework\Constraint\IsIdentical(
$website->getDefaultStore())
97 $this->returnValue($timeout)
100 $this->_helper->expects($this->never())->method(
'getConfig');
102 $this->_adminHelper->expects(
107 $this->equalTo(
'timeout'),
108 new \PHPUnit\Framework\Constraint\IsNull()
110 $this->returnValue($timeout)
113 $timesToCall = isset(
$website) ? 2 : 1;
114 $this->_directory->expects(
115 $this->exactly($timesToCall)
119 $this->returnValue([$filename])
121 $this->_directory->expects($this->exactly($timesToCall))->method(
'isFile')->will($this->returnValue($isFile));
122 $this->_directory->expects($this->any())->method(
'stat')->will($this->returnValue([
'mtime' => $mTime]));
124 $this->_deleteExpiredImages->execute();
132 $website = $this->createPartialMock(\
Magento\Store\Model\Website::class, [
'__wakeup',
'getDefaultStore']);
133 $store = $this->createPartialMock(\
Magento\Store\Model\Store::class, [
'__wakeup']);
134 $website->expects($this->any())->method(
'getDefaultStore')->will($this->returnValue(
$store));
137 [
null,
true,
'test.png', 50, ($time - 60) / 60,
true],
138 [
$website,
false,
'test.png', 50, ($time - 60) / 60,
false],
139 [
$website,
true,
'test.jpg', 50, ($time - 60) / 60,
false],
140 [
$website,
true,
'test.png', 50, ($time - 20) / 60,
false]
testDeleteExpiredImages($website, $isFile, $filename, $mTime, $timeout)