CacheStatusCommandTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\CacheStatusCommand;
  8. use Symfony\Component\Console\Tester\CommandTester;
  9. class CacheStatusCommandTest extends AbstractCacheCommandTest
  10. {
  11. protected function setUp()
  12. {
  13. parent::setUp();
  14. $this->command = new CacheStatusCommand($this->cacheManagerMock);
  15. }
  16. public function testExecute()
  17. {
  18. $cacheTypes = ['A' => 0, 'B' => 1, 'C' => 1];
  19. $this->cacheManagerMock->expects($this->once())->method('getStatus')->willReturn($cacheTypes);
  20. $commandTester = new CommandTester($this->command);
  21. $commandTester->execute([]);
  22. $this->assertEquals($this->getExpectedExecutionOutput($cacheTypes), $commandTester->getDisplay());
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function getExpectedExecutionOutput(array $types)
  28. {
  29. $output = 'Current status:' . PHP_EOL;
  30. foreach ($types as $type => $status) {
  31. $output .= sprintf('%30s: %d', $type, $status) . PHP_EOL;
  32. }
  33. return $output;
  34. }
  35. }