diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-17 00:04:55 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-17 18:38:28 +0200 |
commit | 2ec68b1eb90aca54e69defd42bf0a610a09f4f49 (patch) | |
tree | 836365d1736cde0b3a887d6944b794741d5ea16b /tests | |
parent | 81b4ced07653e8d66004b76db659cbabe06e65b5 (diff) | |
download | nextcloud-server-2ec68b1eb90aca54e69defd42bf0a610a09f4f49.tar.gz nextcloud-server-2ec68b1eb90aca54e69defd42bf0a610a09f4f49.zip |
refactor(Log): Use new in initializer instead of constructor body
PHP 8.1 allows us to now move the `new` into the initializer,
this makes the code a bit nicer (and 3 lines shorter).
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/LoggerTest.php | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php index 6343ce62065..888190bcd97 100644 --- a/tests/lib/LoggerTest.php +++ b/tests/lib/LoggerTest.php @@ -17,14 +17,11 @@ use OCP\Support\CrashReport\IRegistry; use PHPUnit\Framework\MockObject\MockObject; class LoggerTest extends TestCase implements IWriter { - /** @var SystemConfig|MockObject */ - private $config; + private SystemConfig&MockObject $config; - /** @var IRegistry|MockObject */ - private $registry; + private IRegistry&MockObject $registry; - /** @var ILogger */ - private $logger; + private Log $logger; /** @var array */ private array $logs = []; @@ -35,7 +32,7 @@ class LoggerTest extends TestCase implements IWriter { $this->logs = []; $this->config = $this->createMock(SystemConfig::class); $this->registry = $this->createMock(IRegistry::class); - $this->logger = new Log($this, $this->config, null, $this->registry); + $this->logger = new Log($this, $this->config, crashReporters: $this->registry); } private function mockDefaultLogLevel(): void { @@ -165,6 +162,7 @@ class LoggerTest extends TestCase implements IWriter { public function testLoggingWithDataArray(): void { $this->mockDefaultLogLevel(); + /** @var IWriter&MockObject */ $writerMock = $this->createMock(IWriter::class); $logFile = new Log($writerMock, $this->config); $writerMock->expects($this->once())->method('write')->with('no app in context', ['something' => 'extra', 'message' => 'Testing logging with john']); |