diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-03-11 15:26:52 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-03-15 12:50:22 +0100 |
commit | 0aa83511a1ee7813a3a55a8901b6f146d51fef01 (patch) | |
tree | 7d451646161c1c8f93a93f7a30fc117b0399a5ed /tests | |
parent | d4a8d5d2ea6e5dd07aa05f2a8fa75689ec15ce5f (diff) | |
download | nextcloud-server-0aa83511a1ee7813a3a55a8901b6f146d51fef01.tar.gz nextcloud-server-0aa83511a1ee7813a3a55a8901b6f146d51fef01.zip |
remove old share propagation entries from appconfig
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/repair/repairsharepropagation.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/lib/repair/repairsharepropagation.php b/tests/lib/repair/repairsharepropagation.php new file mode 100644 index 00000000000..6ec8b98ec56 --- /dev/null +++ b/tests/lib/repair/repairsharepropagation.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright (c) 2016 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\Repair; + +use OC\Repair\SharePropagation; + +class RepairSharePropagation extends \Test\TestCase { + public function keyProvider() { + return [ + [['1', '2'], ['1', '2']], + [['1', '2', 'foo'], ['1', '2']], + [['foo'], []], + ]; + } + + /** + * @dataProvider keyProvider + * @param array $startKeys + * @param array $expectedRemovedKeys + */ + public function testRemovePropagationEntries(array $startKeys, array $expectedRemovedKeys) { + /** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\IConfig $config */ + $config = $this->getMock('\OCP\IConfig'); + $config->expects($this->once()) + ->method('getAppKeys') + ->with('files_sharing') + ->will($this->returnValue($startKeys)); + + $removedKeys = []; + + $config->expects($this->any()) + ->method('deleteAppValue') + ->will($this->returnCallback(function ($app, $key) use (&$removedKeys) { + $removedKeys[] = $key; + })); + + $step = new SharePropagation($config); + $step->run(); + + sort($expectedRemovedKeys); + sort($removedKeys); + + $this->assertEquals($expectedRemovedKeys, $removedKeys); + } +} |