aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2021-10-25 16:16:55 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2021-11-23 09:29:01 +0100
commit8b271b8a123f0f0cbf3a3d81cf9cf3f99a2e642e (patch)
tree2a9aab48581704506965f8ff7628d25e13fa0042 /tests/Core/Command
parentcd72045433eafc8f73a620239dc5afa6a0a6d84d (diff)
downloadnextcloud-server-8b271b8a123f0f0cbf3a3d81cf9cf3f99a2e642e.tar.gz
nextcloud-server-8b271b8a123f0f0cbf3a3d81cf9cf3f99a2e642e.zip
Fix tests and avoid PHP errors in them
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/Core/Command')
-rw-r--r--tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php7
-rw-r--r--tests/Core/Command/Log/FileTest.php3
-rw-r--r--tests/Core/Command/Preview/RepairTest.php7
3 files changed, 14 insertions, 3 deletions
diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
index 02cc824ee0c..fc916ad4099 100644
--- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
+++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
@@ -74,9 +74,12 @@ class ChangeKeyStorageRootTest extends TestCase {
$this->outputInterface = $this->getMockBuilder(OutputInterface::class)->getMock();
$this->userInterface = $this->getMockBuilder(UserInterface::class)->getMock();
- $outputFormatterInterface = $this->getMockBuilder(OutputFormatterInterface::class)->getMock();
+ /* We need format method to return a string */
+ $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+ $outputFormatter->method('format')->willReturnArgument(0);
+
$this->outputInterface->expects($this->any())->method('getFormatter')
- ->willReturn($outputFormatterInterface);
+ ->willReturn($outputFormatter);
$this->changeKeyStorageRoot = new ChangeKeyStorageRoot(
$this->view,
diff --git a/tests/Core/Command/Log/FileTest.php b/tests/Core/Command/Log/FileTest.php
index 1a8a86759f5..103888de287 100644
--- a/tests/Core/Command/Log/FileTest.php
+++ b/tests/Core/Command/Log/FileTest.php
@@ -51,6 +51,7 @@ class FileTest extends TestCase {
}
public function testEnable() {
+ $this->config->method('getSystemValue')->willReturnArgument(1);
$this->consoleInput->method('getOption')
->willReturnMap([
['enable', 'true']
@@ -63,6 +64,7 @@ class FileTest extends TestCase {
}
public function testChangeFile() {
+ $this->config->method('getSystemValue')->willReturnArgument(1);
$this->consoleInput->method('getOption')
->willReturnMap([
['file', '/foo/bar/file.log']
@@ -87,6 +89,7 @@ class FileTest extends TestCase {
* @dataProvider changeRotateSizeProvider
*/
public function testChangeRotateSize($optionValue, $configValue) {
+ $this->config->method('getSystemValue')->willReturnArgument(1);
$this->consoleInput->method('getOption')
->willReturnMap([
['rotate-size', $optionValue]
diff --git a/tests/Core/Command/Preview/RepairTest.php b/tests/Core/Command/Preview/RepairTest.php
index c37e57f848c..a6591745817 100644
--- a/tests/Core/Command/Preview/RepairTest.php
+++ b/tests/Core/Command/Preview/RepairTest.php
@@ -68,9 +68,14 @@ class RepairTest extends TestCase {
$this->output->expects($this->any())
->method('section')
->willReturn($this->output);
+
+ /* We need format method to return a string */
+ $outputFormatter = $this->createMock(OutputFormatterInterface::class);
+ $outputFormatter->method('format')->willReturnArgument(0);
+
$this->output->expects($this->any())
->method('getFormatter')
- ->willReturn($this->getMockBuilder(OutputFormatterInterface::class)->getMock());
+ ->willReturn($outputFormatter);
$this->output->expects($this->any())
->method('writeln')
->willReturnCallback(function ($line) use ($self) {