示例#1
0
 /**
  * @dataProvider getExpiredImages
  */
 public function testDeleteExpiredImages($website, $isFile, $filename, $mTime, $timeout, $mustDelete)
 {
     $this->_storeManager->expects($this->once())->method('getWebsites')->will($this->returnValue(isset($website) ? [$website] : []));
     if (isset($website)) {
         $this->_helper->expects($this->once())->method('getConfig')->with($this->equalTo('timeout'), new \PHPUnit_Framework_Constraint_IsIdentical($website->getDefaultStore()))->will($this->returnValue($timeout));
     } else {
         $this->_helper->expects($this->never())->method('getConfig');
     }
     $this->_adminHelper->expects($this->once())->method('getConfig')->with($this->equalTo('timeout'), new \PHPUnit_Framework_Constraint_IsNull())->will($this->returnValue($timeout));
     $timesToCall = isset($website) ? 2 : 1;
     $this->_directory->expects($this->exactly($timesToCall))->method('read')->will($this->returnValue([$filename]));
     $this->_directory->expects($this->exactly($timesToCall))->method('isFile')->will($this->returnValue($isFile));
     $this->_directory->expects($this->any())->method('stat')->will($this->returnValue(['mtime' => $mTime]));
     if ($mustDelete) {
         $this->_directory->expects($this->exactly($timesToCall))->method('delete')->with($filename);
     } else {
         $this->_directory->expects($this->never())->method('delete');
     }
     $this->_model->deleteExpiredImages();
 }
示例#2
0
 /**
  * @covers \Magento\Captcha\Helper\Adminhtml\Data::_getWebsiteCode
  */
 public function testGetWebsiteId()
 {
     $this->assertStringEndsWith('/admin/', $this->_model->getImgDir());
 }