1
0

ClearGeneratedAvatarCacheTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 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 Test\Repair;
  24. use OCP\IConfig;
  25. use OCP\Migration\IOutput;
  26. use OC\Avatar\AvatarManager;
  27. use OC\Repair\ClearGeneratedAvatarCache;
  28. class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
  29. /** @var AvatarManager */
  30. private $avatarManager;
  31. /** @var IOutput */
  32. private $outputMock;
  33. /** @var IConfig */
  34. private $config;
  35. /** @var ClearGeneratedAvatarCache */
  36. protected $repair;
  37. protected function setUp() {
  38. parent::setUp();
  39. $this->outputMock = $this->createMock(IOutput::class);
  40. $this->avatarManager = $this->createMock(AvatarManager::class);
  41. $this->config = $this->createMock(IConfig::class);
  42. $this->repair = new ClearGeneratedAvatarCache($this->config, $this->avatarManager);
  43. }
  44. public function shouldRunDataProvider() {
  45. return [
  46. ['11.0.0.0', true],
  47. ['15.0.0.3', true],
  48. ['13.0.5.2', true],
  49. ['12.0.0.0', true],
  50. ['16.0.0.1', false],
  51. ['15.0.0.2', true],
  52. ['13.0.0.0', true],
  53. ['15.0.0.5', false]
  54. ];
  55. }
  56. /**
  57. * @dataProvider shouldRunDataProvider
  58. *
  59. * @param string $from
  60. * @param boolean $expected
  61. */
  62. public function testShouldRun($from, $expected) {
  63. $this->config->expects($this->any())
  64. ->method('getSystemValue')
  65. ->with('version', '0.0.0.0')
  66. ->willReturn($from);
  67. $this->assertEquals($expected, $this->invokePrivate($this->repair, 'shouldRun'));
  68. }
  69. }