aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-02-24 08:52:26 +0100
committerGitHub <noreply@github.com>2017-02-24 08:52:26 +0100
commitb26568133f00771ed92f22fd5d6d45c6e595e8bb (patch)
tree6b3a259ba3bbd6751446a54f5bc58e2db9cff904 /tests
parent97b6c1496e76042e3582941aa7411e455fe9d3b8 (diff)
parent9533f4e5edfded577b67d08f7778a8a1704132f2 (diff)
downloadnextcloud-server-b26568133f00771ed92f22fd5d6d45c6e595e8bb.tar.gz
nextcloud-server-b26568133f00771ed92f22fd5d6d45c6e595e8bb.zip
Merge pull request #3605 from nextcloud/single-user
Clean up single user mode
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Command/Encryption/DecryptAllTest.php14
-rw-r--r--tests/Core/Command/Encryption/EncryptAllTest.php10
-rw-r--r--tests/Core/Command/Maintenance/SingleUserTest.php132
3 files changed, 12 insertions, 144 deletions
diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php
index 8f674aa5b44..1b01231ac57 100644
--- a/tests/Core/Command/Encryption/DecryptAllTest.php
+++ b/tests/Core/Command/Encryption/DecryptAllTest.php
@@ -77,7 +77,7 @@ class DecryptAllTest extends TestCase {
$this->config->expects($this->any())
->method('getSystemValue')
- ->with('singleuser', false)
+ ->with('maintenance', false)
->willReturn(false);
$this->appManager->expects($this->any())
->method('isEnabledForUser')
@@ -85,12 +85,12 @@ class DecryptAllTest extends TestCase {
}
- public function testSingleUserAndTrashbin() {
+ public function testMaintenanceAndTrashbin() {
// on construct we enable single-user-mode and disable the trash bin
$this->config->expects($this->at(1))
->method('setSystemValue')
- ->with('singleuser', true);
+ ->with('maintenance', true);
$this->appManager->expects($this->once())
->method('disableApp')
->with('files_trashbin');
@@ -98,7 +98,7 @@ class DecryptAllTest extends TestCase {
// on destruct wi disable single-user-mode again and enable the trash bin
$this->config->expects($this->at(2))
->method('setSystemValue')
- ->with('singleuser', false);
+ ->with('maintenance', false);
$this->appManager->expects($this->once())
->method('enableApp')
->with('files_trashbin');
@@ -110,16 +110,16 @@ class DecryptAllTest extends TestCase {
$this->decryptAll,
$this->questionHelper
);
- $this->invokePrivate($instance, 'forceSingleUserAndTrashbin');
+ $this->invokePrivate($instance, 'forceMaintenanceAndTrashbin');
$this->assertTrue(
$this->invokePrivate($instance, 'wasTrashbinEnabled')
);
$this->assertFalse(
- $this->invokePrivate($instance, 'wasSingleUserModeEnabled')
+ $this->invokePrivate($instance, 'wasMaintenanceModeEnabled')
);
- $this->invokePrivate($instance, 'resetSingleUserAndTrashbin');
+ $this->invokePrivate($instance, 'resetMaintenanceAndTrashbin');
}
/**
diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php
index 00895541782..554560a35b7 100644
--- a/tests/Core/Command/Encryption/EncryptAllTest.php
+++ b/tests/Core/Command/Encryption/EncryptAllTest.php
@@ -88,13 +88,13 @@ class EncryptAllTest extends TestCase {
$this->appManager->expects($this->once())->method('disableApp')->with('files_trashbin');
// enable single user mode to avoid that other user login during encryption
// destructor should disable the single user mode again
- $this->config->expects($this->once())->method('getSystemValue')->with('singleuser', false)->willReturn(false);
- $this->config->expects($this->at(1))->method('setSystemValue')->with('singleuser', true);
- $this->config->expects($this->at(2))->method('setSystemValue')->with('singleuser', false);
+ $this->config->expects($this->once())->method('getSystemValue')->with('maintenance', false)->willReturn(false);
+ $this->config->expects($this->at(1))->method('setSystemValue')->with('maintenance', true);
+ $this->config->expects($this->at(2))->method('setSystemValue')->with('maintenance', false);
$instance = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
- $this->invokePrivate($instance, 'forceSingleUserAndTrashbin');
- $this->invokePrivate($instance, 'resetSingleUserAndTrashbin');
+ $this->invokePrivate($instance, 'forceMaintenanceAndTrashbin');
+ $this->invokePrivate($instance, 'resetMaintenanceAndTrashbin');
}
/**
diff --git a/tests/Core/Command/Maintenance/SingleUserTest.php b/tests/Core/Command/Maintenance/SingleUserTest.php
deleted file mode 100644
index 13efebacb0a..00000000000
--- a/tests/Core/Command/Maintenance/SingleUserTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-/**
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace Tests\Core\Command\Maintenance;
-
-
-use OC\Core\Command\Maintenance\SingleUser;
-use OCP\IConfig;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-use Test\TestCase;
-
-class SingleUserTest extends TestCase {
- /** @var \PHPUnit_Framework_MockObject_MockObject */
- protected $config;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
- protected $consoleInput;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
- protected $consoleOutput;
-
- /** @var \Symfony\Component\Console\Command\Command */
- protected $command;
-
- protected function setUp() {
- parent::setUp();
-
- $config = $this->config = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
- $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
-
- /** @var \OCP\IConfig $config */
- $this->command = new SingleUser($config);
- }
-
- public function testChangeStateToOn() {
-
- $this->consoleInput->expects($this->once())
- ->method('getOption')
- ->with('on')
- ->willReturn(true);
-
- $this->config->expects($this->once())
- ->method('setSystemValue')
- ->with('singleuser', true);
-
- $this->consoleOutput->expects($this->once())
- ->method('writeln')
- ->with('Single user mode enabled');
-
- self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
- }
-
- public function testChangeStateToOff() {
-
- $this->consoleInput->expects($this->at(0))
- ->method('getOption')
- ->with('on')
- ->willReturn(false);
-
- $this->consoleInput->expects($this->at(1))
- ->method('getOption')
- ->with('off')
- ->willReturn(true);
-
- $this->config->expects($this->once())
- ->method('setSystemValue')
- ->with('singleuser', false);
-
- $this->consoleOutput->expects($this->once())
- ->method('writeln')
- ->with('Single user mode disabled');
-
- self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
- }
-
- public function stateData() {
- return [
- [ true, 'Single user mode is currently enabled' ],
- [ false, 'Single user mode is currently disabled' ],
- ];
- }
-
- /**
- * @dataProvider stateData
- *
- * @param $state
- * @param $expectedOutput
- */
- public function testState($state, $expectedOutput) {
-
- $this->consoleInput->expects($this->at(0))
- ->method('getOption')
- ->with('on')
- ->willReturn(false);
-
- $this->consoleInput->expects($this->at(1))
- ->method('getOption')
- ->with('off')
- ->willReturn(false);
-
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('singleuser', false)
- ->willReturn($state);
-
- $this->consoleOutput->expects($this->once())
- ->method('writeln')
- ->with($expectedOutput);
-
- self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
- }
-}