2016-03-11 17:26:52 +03:00
|
|
|
<?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;
|
2016-09-07 21:18:58 +03:00
|
|
|
use OCP\IConfig;
|
2016-04-22 16:35:39 +03:00
|
|
|
use OCP\Migration\IOutput;
|
2016-03-11 17:26:52 +03:00
|
|
|
|
2016-05-20 16:38:20 +03:00
|
|
|
class RepairSharePropagationTest extends \Test\TestCase {
|
2016-03-11 17:26:52 +03:00
|
|
|
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 */
|
2016-09-07 21:18:58 +03:00
|
|
|
$config = $this->createMock(IConfig::class);
|
2016-03-11 17:26:52 +03:00
|
|
|
$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;
|
|
|
|
}));
|
|
|
|
|
2016-04-22 16:35:39 +03:00
|
|
|
/** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
|
|
|
|
$outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
2016-03-11 17:26:52 +03:00
|
|
|
$step = new SharePropagation($config);
|
2016-04-22 16:35:39 +03:00
|
|
|
$step->run($outputMock);
|
2016-03-11 17:26:52 +03:00
|
|
|
|
|
|
|
sort($expectedRemovedKeys);
|
|
|
|
sort($removedKeys);
|
|
|
|
|
|
|
|
$this->assertEquals($expectedRemovedKeys, $removedKeys);
|
|
|
|
}
|
|
|
|
}
|