l10n = $this->createMock(IL10N::class); $this->l10n->expects($this->any()) ->method('t') ->willReturnCallback(function ($message, array $replace) { return vsprintf($message, $replace); }); $this->config = $this->createMock(IConfig::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); } public static function dataRun(): array { return [ [ILogger::INFO, SetupResult::SUCCESS], [ILogger::WARN, SetupResult::SUCCESS], [ILogger::ERROR, SetupResult::SUCCESS], [ILogger::FATAL, SetupResult::SUCCESS], // Debug is valid but will result in an warning [ILogger::DEBUG, SetupResult::WARNING], // negative - invalid range [-1, SetupResult::ERROR], // string value instead of number ['1', SetupResult::ERROR], // random string value ['error', SetupResult::ERROR], // PSR logger value [LogLevel::ALERT, SetupResult::ERROR], // out of range [ILogger::FATAL + 1, SetupResult::ERROR], ]; } /** @dataProvider dataRun */ public function testRun(mixed $value, string $expected): void { $this->urlGenerator->method('linkToDocs')->willReturn('admin-logging'); $this->config->expects(self::once()) ->method('getSystemValue') ->with('loglevel', ILogger::WARN) ->willReturn($value); $check = new LoggingLevel($this->l10n, $this->config, $this->urlGenerator); $result = $check->run(); $this->assertEquals($expected, $result->getSeverity()); } }