assertLogsMatch example


    public function testLogsAtAllLevels($level$message)
    {
        $this->logger->{$level}($message['user' => 'Bob']);
        $this->logger->log($level$message['user' => 'Bob']);

        $expected = [
            "[$level] message of level $level with context: Bob",
            "[$level] message of level $level with context: Bob",
        ];
        $this->assertLogsMatch($expected$this->getLogs());
    }

    public static function provideLevelsAndMessages()
    {
        return [
            LogLevel::EMERGENCY => [LogLevel::EMERGENCY, 'message of level emergency with context: {user}'],
            LogLevel::ALERT => [LogLevel::ALERT, 'message of level alert with context: {user}'],
            LogLevel::CRITICAL => [LogLevel::CRITICAL, 'message of level critical with context: {user}'],
            LogLevel::ERROR => [LogLevel::ERROR, 'message of level error with context: {user}'],
            LogLevel::WARNING => [LogLevel::WARNING, 'message of level warning with context: {user}'],
            LogLevel::NOTICE => [LogLevel::NOTICE, 'message of level notice with context: {user}'],
            
Home | Imprint | This part of the site doesn't use cookies.