summaryrefslogtreecommitdiffstats
path: root/tests/lib/Repair
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-11-19 20:26:53 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-19 20:26:53 +0100
commit78a318d388bfe82e1a3adebeb75ac195cb1334d7 (patch)
tree5815fe69df96b1963c5774a4b40a052abbf58300 /tests/lib/Repair
parentccb05dbb170475870e755573f91da6e1914698d5 (diff)
downloadnextcloud-server-78a318d388bfe82e1a3adebeb75ac195cb1334d7.tar.gz
nextcloud-server-78a318d388bfe82e1a3adebeb75ac195cb1334d7.zip
Add test if repair step is already done
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/Repair')
-rw-r--r--tests/lib/Repair/NC11/CleanPreviewsTest.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/lib/Repair/NC11/CleanPreviewsTest.php b/tests/lib/Repair/NC11/CleanPreviewsTest.php
index 643f18e89b7..8abc6b7bab9 100644
--- a/tests/lib/Repair/NC11/CleanPreviewsTest.php
+++ b/tests/lib/Repair/NC11/CleanPreviewsTest.php
@@ -25,6 +25,7 @@ namespace Test\Repair\NC11;
use OC\Repair\NC11\CleanPreviews;
use OC\Repair\NC11\CleanPreviewsBackgroundJob;
use OCP\BackgroundJob\IJobList;
+use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Migration\IOutput;
@@ -39,6 +40,9 @@ class CleanPreviewsTest extends TestCase {
/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
private $userManager;
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ private $config;
+
/** @var CleanPreviews */
private $repair;
@@ -47,10 +51,12 @@ class CleanPreviewsTest extends TestCase {
$this->jobList = $this->createMock(IJobList::class);
$this->userManager = $this->createMock(IUserManager::class);
+ $this->config = $this->createMock(IConfig::class);
$this->repair = new CleanPreviews(
$this->jobList,
- $this->userManager
+ $this->userManager,
+ $this->config
);
}
@@ -87,6 +93,42 @@ class CleanPreviewsTest extends TestCase {
$this->equalTo(['uid' => 'user2'])
);
+ $this->config->expects($this->once())
+ ->method('getAppValue')
+ ->with(
+ $this->equalTo('core'),
+ $this->equalTo('previewsCleanedUp'),
+ $this->equalTo(false)
+ )->willReturn(false);
+ $this->config->expects($this->once())
+ ->method('setAppValue')
+ ->with(
+ $this->equalTo('core'),
+ $this->equalTo('previewsCleanedUp'),
+ $this->equalTo(1)
+ );
+
+ $this->repair->run($this->createMock(IOutput::class));
+ }
+
+
+ public function testRunAlreadyDoone() {
+ $this->userManager->expects($this->never())
+ ->method($this->anything());
+
+ $this->jobList->expects($this->never())
+ ->method($this->anything());
+
+ $this->config->expects($this->once())
+ ->method('getAppValue')
+ ->with(
+ $this->equalTo('core'),
+ $this->equalTo('previewsCleanedUp'),
+ $this->equalTo(false)
+ )->willReturn('1');
+ $this->config->expects($this->never())
+ ->method('setAppValue');
+
$this->repair->run($this->createMock(IOutput::class));
}