UpdateTheme.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\Mimetype\UpdateDB;
  25. use OC\Core\Command\Maintenance\UpdateTheme;
  26. use OC\Files\Type\Detection;
  27. use OC\Files\Type\Loader;
  28. use OCP\ICache;
  29. use OCP\ICacheFactory;
  30. use Symfony\Component\Console\Input\InputInterface;
  31. use Symfony\Component\Console\Output\OutputInterface;
  32. use Test\TestCase;
  33. use OCP\Files\IMimeTypeDetector;
  34. use OCP\Files\IMimeTypeLoader;
  35. class UpdateThemeTest extends TestCase {
  36. /** @var IMimeTypeDetector */
  37. protected $detector;
  38. /** @var ICacheFactory */
  39. protected $cacheFactory;
  40. /** @var \PHPUnit_Framework_MockObject_MockObject */
  41. protected $consoleInput;
  42. /** @var \PHPUnit_Framework_MockObject_MockObject */
  43. protected $consoleOutput;
  44. /** @var \Symfony\Component\Console\Command\Command */
  45. protected $command;
  46. protected function setUp() {
  47. parent::setUp();
  48. $this->detector = $this->createMock(Detection::class);
  49. $this->cacheFactory = $this->createMock(ICacheFactory::class);
  50. $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
  51. $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
  52. $this->command = new UpdateTheme($this->detector, $this->cacheFactory);
  53. }
  54. public function testThemeUpdate() {
  55. $this->consoleInput->method('getOption')
  56. ->with('maintenance:theme:update')
  57. ->willReturn(true);
  58. $this->detector->expects($this->once())
  59. ->method('getAllAliases')
  60. ->willReturn([]);
  61. $cache = $this->createMock(ICache::class);
  62. $cache->expects($this->once())
  63. ->method('clear')
  64. ->with('');
  65. $this->cacheFactory->expects($this->once())
  66. ->method('createDistributed')
  67. ->with('imagePath')
  68. ->willReturn($cache);
  69. self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
  70. }
  71. }