UpdateTheme.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
  4. *
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace Tests\Core\Command\Maintenance;
  24. use OC\Core\Command\Maintenance\UpdateTheme;
  25. use OC\Files\Type\Detection;
  26. use OCP\Files\IMimeTypeDetector;
  27. use OCP\ICache;
  28. use OCP\ICacheFactory;
  29. use Symfony\Component\Console\Input\InputInterface;
  30. use Symfony\Component\Console\Output\OutputInterface;
  31. use Test\TestCase;
  32. class UpdateThemeTest extends TestCase {
  33. /** @var IMimeTypeDetector */
  34. protected $detector;
  35. /** @var ICacheFactory */
  36. protected $cacheFactory;
  37. /** @var \PHPUnit\Framework\MockObject\MockObject */
  38. protected $consoleInput;
  39. /** @var \PHPUnit\Framework\MockObject\MockObject */
  40. protected $consoleOutput;
  41. /** @var \Symfony\Component\Console\Command\Command */
  42. protected $command;
  43. protected function setUp(): void {
  44. parent::setUp();
  45. $this->detector = $this->createMock(Detection::class);
  46. $this->cacheFactory = $this->createMock(ICacheFactory::class);
  47. $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
  48. $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
  49. $this->command = new UpdateTheme($this->detector, $this->cacheFactory);
  50. }
  51. public function testThemeUpdate() {
  52. $this->consoleInput->method('getOption')
  53. ->with('maintenance:theme:update')
  54. ->willReturn(true);
  55. $this->detector->expects($this->once())
  56. ->method('getAllAliases')
  57. ->willReturn([]);
  58. $cache = $this->createMock(ICache::class);
  59. $cache->expects($this->once())
  60. ->method('clear')
  61. ->with('');
  62. $this->cacheFactory->expects($this->once())
  63. ->method('createDistributed')
  64. ->with('imagePath')
  65. ->willReturn($cache);
  66. self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
  67. }
  68. }