summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-15 16:04:17 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-15 16:04:17 +0100
commitf7140294f26f7966aa00cfdd49c76a14d39df04e (patch)
treed23c2037d02b3243d38323bf46e41a3bf0551c0a /tests
parent27760ae54e3e28a894ebb610c859fbd3bb8682cc (diff)
parent0aa83511a1ee7813a3a55a8901b6f146d51fef01 (diff)
downloadnextcloud-server-f7140294f26f7966aa00cfdd49c76a14d39df04e.tar.gz
nextcloud-server-f7140294f26f7966aa00cfdd49c76a14d39df04e.zip
Merge pull request #23157 from owncloud/remove-share-prop-entries
remove old share propagation entries from appconfig
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/repair/repairsharepropagation.php51
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);
+ }
+}