AbstractCacheSetCommandTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. abstract class AbstractCacheSetCommandTest extends AbstractCacheManageCommandTest
  8. {
  9. /**
  10. * @return array
  11. */
  12. public function executeDataProvider()
  13. {
  14. return [
  15. 'implicit all' => [
  16. [],
  17. ['A', 'B', 'C'],
  18. ['A', 'B', 'C'],
  19. $this->getExpectedExecutionOutput(['A', 'B', 'C']),
  20. ],
  21. 'specified types' => [
  22. ['types' => ['A', 'B']],
  23. ['A', 'B'],
  24. ['A', 'B'],
  25. $this->getExpectedExecutionOutput(['A', 'B']),
  26. ],
  27. 'no changes' => [
  28. ['types' => ['A', 'B']],
  29. ['A', 'B'],
  30. [],
  31. $this->getExpectedExecutionOutput([]),
  32. ],
  33. ];
  34. }
  35. /**
  36. * Formats expected output of cache status change
  37. *
  38. * @param array $changes
  39. * @param bool $enabled
  40. * @return string
  41. */
  42. public function getExpectedChangeOutput(array $changes, $enabled)
  43. {
  44. if ($changes) {
  45. $output = 'Changed cache status:' . PHP_EOL;
  46. foreach ($changes as $type) {
  47. $output .= sprintf('%30s: %d -> %d', $type, $enabled === false, $enabled === true) . PHP_EOL;
  48. }
  49. } else {
  50. $output = 'There is nothing to change in cache status' . PHP_EOL;
  51. }
  52. return $output;
  53. }
  54. }