From 8b271b8a123f0f0cbf3a3d81cf9cf3f99a2e642e Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Mon, 25 Oct 2021 16:16:55 +0200 Subject: Fix tests and avoid PHP errors in them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php | 7 +++++-- tests/Core/Command/Log/FileTest.php | 3 +++ tests/Core/Command/Preview/RepairTest.php | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'tests/Core/Command') 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) { -- cgit v1.2.3