CacheCleanCommandTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Test\Unit\Console\Command;
  7. use Magento\Backend\Console\Command\CacheCleanCommand;
  8. use Symfony\Component\Console\Tester\CommandTester;
  9. class CacheCleanCommandTest extends AbstractCacheManageCommandTest
  10. {
  11. protected function setUp()
  12. {
  13. $this->cacheEventName = 'adminhtml_cache_flush_system';
  14. parent::setUp();
  15. $this->command = new CacheCleanCommand($this->cacheManagerMock, $this->eventManagerMock);
  16. }
  17. /**
  18. * @param array $param
  19. * @param array $types
  20. * @param string $output
  21. * @dataProvider executeDataProvider
  22. */
  23. public function testExecute($param, $types, $output)
  24. {
  25. $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
  26. $this->cacheManagerMock->expects($this->once())->method('clean')->with($types);
  27. $this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
  28. $commandTester = new CommandTester($this->command);
  29. $commandTester->execute($param);
  30. $this->assertEquals($output, $commandTester->getDisplay());
  31. }
  32. /**
  33. * Get expected output based on set of types operated on
  34. *
  35. * @param array $types
  36. * @return string
  37. */
  38. public function getExpectedExecutionOutput(array $types)
  39. {
  40. return 'Cleaned cache types:' . PHP_EOL . implode(PHP_EOL, $types) . PHP_EOL;
  41. }
  42. }