Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CleanCacheTest.php
Go to the documentation of this file.
1 <?php
7 
8 class CleanCacheTest extends \PHPUnit\Framework\TestCase
9 {
10  public function testCleanCache()
11  {
12  $cacheBackendMock = $this->getMockForAbstractClass(\Zend_Cache_Backend_Interface::class);
13  $cacheFrontendMock = $this->getMockForAbstractClass(\Magento\Framework\Cache\FrontendInterface::class);
14  $frontendPoolMock = $this->createMock(\Magento\Framework\App\Cache\Frontend\Pool::class);
15 
16  $cacheBackendMock->expects(
17  $this->once()
18  )->method(
19  'clean'
20  )->with(
22  []
23  );
24 
25  $cacheFrontendMock->expects(
26  $this->once()
27  )->method(
28  'getBackend'
29  )->will(
30  $this->returnValue($cacheBackendMock)
31  );
32 
33  $frontendPoolMock->expects(
34  $this->any()
35  )->method(
36  'valid'
37  )->will(
38  $this->onConsecutiveCalls(true, false)
39  );
40 
41  $frontendPoolMock->expects(
42  $this->any()
43  )->method(
44  'current'
45  )->will(
46  $this->returnValue($cacheFrontendMock)
47  );
48 
49  $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
53  $model = $objectManagerHelper->getObject(
54  \Magento\Backend\Cron\CleanCache::class,
55  [
56  'cacheFrontendPool' => $frontendPoolMock,
57  ]
58  );
59 
60  $model->execute();
61  }
62 }
const CLEANING_MODE_OLD
Definition: Cache.php:73