Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheCleanCommandTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Symfony\Component\Console\Tester\CommandTester;
11 
13 {
14  protected function setUp()
15  {
16  $this->cacheEventName = 'adminhtml_cache_flush_system';
17  parent::setUp();
18  $this->command = new CacheCleanCommand($this->cacheManagerMock, $this->eventManagerMock);
19  }
20 
27  public function testExecute($param, $types, $output)
28  {
29  $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
30  $this->cacheManagerMock->expects($this->once())->method('clean')->with($types);
31  $this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
32 
33  $commandTester = new CommandTester($this->command);
34  $commandTester->execute($param);
35 
36  $this->assertEquals($output, $commandTester->getDisplay());
37  }
38 
45  public function getExpectedExecutionOutput(array $types)
46  {
47  return 'Cleaned cache types:' . PHP_EOL . implode(PHP_EOL, $types) . PHP_EOL;
48  }
49 }