Browse Source

fix: Adjust console formatter code to match with Symfony type hints

Symfony has added type hints on the `OutputFormatterInterface`,
so we must adjust our type hints to match with Symfony.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
tags/v27.0.0beta1
Ferdinand Thiessen 1 year ago
parent
commit
dc9d8c42bb

+ 4
- 1
apps/encryption/tests/Crypto/EncryptAllTest.php View File

@@ -121,6 +121,7 @@ class EncryptAllTest extends TestCase {

/* We need format method to return a string */
$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('isDecorated')->willReturn(false);
$outputFormatter->method('format')->willReturnArgument(0);

$this->outputInterface->expects($this->any())->method('getFormatter')
@@ -346,9 +347,11 @@ class EncryptAllTest extends TestCase {
['/user1/files/foo/subfile'],
);

$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('isDecorated')->willReturn(false);
$this->outputInterface->expects($this->any())
->method('getFormatter')
->willReturn($this->createMock(OutputFormatterInterface::class));
->willReturn($outputFormatter);
$progressBar = new ProgressBar($this->outputInterface);

$this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']);

+ 3
- 3
lib/private/Console/TimestampFormatter.php View File

@@ -94,11 +94,11 @@ class TimestampFormatter implements OutputFormatterInterface {
/**
* Formats a message according to the given styles.
*
* @param string $message The message to style
* @return string The styled message, prepended with a timestamp using the
* @param string|null $message The message to style
* @return string|null The styled message, prepended with a timestamp using the
* log timezone and dateformat, e.g. "2015-06-23T17:24:37+02:00"
*/
public function format($message) {
public function format(?string $message): ?string {
if (!$this->formatter->isDecorated()) {
// Don't add anything to the output when we shouldn't
return $this->formatter->format($message);

+ 1
- 0
tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php View File

@@ -75,6 +75,7 @@ class ChangeKeyStorageRootTest extends TestCase {

/* We need format method to return a string */
$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('isDecorated')->willReturn(false);
$outputFormatter->method('format')->willReturnArgument(0);

$this->outputInterface->expects($this->any())->method('getFormatter')

+ 1
- 0
tests/Core/Command/Preview/RepairTest.php View File

@@ -71,6 +71,7 @@ class RepairTest extends TestCase {

/* We need format method to return a string */
$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('isDecorated')->willReturn(false);
$outputFormatter->method('format')->willReturnArgument(0);

$this->output->expects($this->any())

+ 4
- 0
tests/lib/Encryption/DecryptAllTest.php View File

@@ -77,12 +77,15 @@ class DecryptAllTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->outputInterface = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()->getMock();
$this->outputInterface->expects($this->any())->method('isDecorated')
->willReturn(false);
$this->userInterface = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock();

/* We need format method to return a string */
$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('format')->willReturn('foo');
$outputFormatter->method('isDecorated')->willReturn(false);

$this->outputInterface->expects($this->any())->method('getFormatter')
->willReturn($outputFormatter);
@@ -304,6 +307,7 @@ class DecryptAllTest extends TestCase {

/* We need format method to return a string */
$outputFormatter = $this->createMock(OutputFormatterInterface::class);
$outputFormatter->method('isDecorated')->willReturn(false);
$outputFormatter->method('format')->willReturn('foo');

$output = $this->createMock(OutputInterface::class);

Loading…
Cancel
Save