You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

  1. <?php
  2. /**
  3. * Copyright (c) 2016 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\Repair;
  9. use OC\Repair\SharePropagation;
  10. use OCP\Migration\IOutput;
  11. class RepairSharePropagationTest extends \Test\TestCase {
  12. public function keyProvider() {
  13. return [
  14. [['1', '2'], ['1', '2']],
  15. [['1', '2', 'foo'], ['1', '2']],
  16. [['foo'], []],
  17. ];
  18. }
  19. /**
  20. * @dataProvider keyProvider
  21. * @param array $startKeys
  22. * @param array $expectedRemovedKeys
  23. */
  24. public function testRemovePropagationEntries(array $startKeys, array $expectedRemovedKeys) {
  25. /** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\IConfig $config */
  26. $config = $this->getMock('\OCP\IConfig');
  27. $config->expects($this->once())
  28. ->method('getAppKeys')
  29. ->with('files_sharing')
  30. ->will($this->returnValue($startKeys));
  31. $removedKeys = [];
  32. $config->expects($this->any())
  33. ->method('deleteAppValue')
  34. ->will($this->returnCallback(function ($app, $key) use (&$removedKeys) {
  35. $removedKeys[] = $key;
  36. }));
  37. /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
  38. $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
  39. ->disableOriginalConstructor()
  40. ->getMock();
  41. $step = new SharePropagation($config);
  42. $step->run($outputMock);
  43. sort($expectedRemovedKeys);
  44. sort($removedKeys);
  45. $this->assertEquals($expectedRemovedKeys, $removedKeys);
  46. }
  47. }