AbstractCacheManageCommandTest.php 1.6 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. use Symfony\Component\Console\Tester\CommandTester;
  8. abstract class AbstractCacheManageCommandTest extends AbstractCacheCommandTest
  9. {
  10. /** @var string */
  11. protected $cacheEventName;
  12. /** @var \Magento\Framework\Event\ManagerInterface | \PHPUnit_Framework_MockObject_MockObject */
  13. protected $eventManagerMock;
  14. protected function setUp()
  15. {
  16. $this->eventManagerMock = $this->getMockBuilder(\Magento\Framework\Event\ManagerInterface::class)
  17. ->disableOriginalConstructor()
  18. ->getMock();
  19. parent::setUp();
  20. }
  21. /**
  22. * @return array
  23. */
  24. public function executeDataProvider()
  25. {
  26. return [
  27. 'implicit all' => [
  28. [],
  29. ['A', 'B', 'C'],
  30. $this->getExpectedExecutionOutput(['A', 'B', 'C']),
  31. ],
  32. 'specified types' => [
  33. ['types' => ['A', 'B']],
  34. ['A', 'B'],
  35. $this->getExpectedExecutionOutput(['A', 'B']),
  36. ],
  37. ];
  38. }
  39. /**
  40. * @expectedException \InvalidArgumentException
  41. * @expectedExceptionMessage The following requested cache types are not supported:
  42. */
  43. public function testExecuteInvalidCacheType()
  44. {
  45. $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
  46. $param = ['types' => ['A', 'D']];
  47. $commandTester = new CommandTester($this->command);
  48. $commandTester->execute($param);
  49. }
  50. }