Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheEnableCommandTest.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  parent::setUp();
17  $this->command = new CacheEnableCommand($this->cacheManagerMock);
18  }
19 
27  public function testExecute($param, $enable, $result, $output)
28  {
29  $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
30  $this->cacheManagerMock->expects($this->once())
31  ->method('setEnabled')
32  ->with($enable, true)
33  ->willReturn($result);
34  $cleanInvocationCount = $result === [] ? 0 : 1;
35  $this->cacheManagerMock->expects($this->exactly($cleanInvocationCount))
36  ->method('clean')
37  ->with($enable);
38 
39  $commandTester = new CommandTester($this->command);
40  $commandTester->execute($param);
41 
42  $this->assertEquals($output, $commandTester->getDisplay());
43  }
44 
48  public function getExpectedExecutionOutput(array $enabled)
49  {
50  $output = $this->getExpectedChangeOutput($enabled, true);
51  if ($enabled) {
52  $output .= 'Cleaned cache types:' . PHP_EOL;
53  $output .= implode(PHP_EOL, $enabled) . PHP_EOL;
54  }
55  return $output;
56  }
57 }