UpdateTheme.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Tests\Core\Command\Maintenance;
  7. use OC\Core\Command\Maintenance\UpdateTheme;
  8. use OC\Files\Type\Detection;
  9. use OCP\Files\IMimeTypeDetector;
  10. use OCP\ICache;
  11. use OCP\ICacheFactory;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. use Test\TestCase;
  15. class UpdateThemeTest extends TestCase {
  16. /** @var IMimeTypeDetector */
  17. protected $detector;
  18. /** @var ICacheFactory */
  19. protected $cacheFactory;
  20. /** @var \PHPUnit\Framework\MockObject\MockObject */
  21. protected $consoleInput;
  22. /** @var \PHPUnit\Framework\MockObject\MockObject */
  23. protected $consoleOutput;
  24. /** @var \Symfony\Component\Console\Command\Command */
  25. protected $command;
  26. protected function setUp(): void {
  27. parent::setUp();
  28. $this->detector = $this->createMock(Detection::class);
  29. $this->cacheFactory = $this->createMock(ICacheFactory::class);
  30. $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
  31. $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
  32. $this->command = new UpdateTheme($this->detector, $this->cacheFactory);
  33. }
  34. public function testThemeUpdate(): void {
  35. $this->consoleInput->method('getOption')
  36. ->with('maintenance:theme:update')
  37. ->willReturn(true);
  38. $this->detector->expects($this->once())
  39. ->method('getAllAliases')
  40. ->willReturn([]);
  41. $cache = $this->createMock(ICache::class);
  42. $cache->expects($this->once())
  43. ->method('clear')
  44. ->with('');
  45. $this->cacheFactory->expects($this->once())
  46. ->method('createDistributed')
  47. ->with('imagePath')
  48. ->willReturn($cache);
  49. self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
  50. }
  51. }