HtmlFormatter example

$records = [
            $this->getRecord(Logger::DEBUG),
            $this->getRecord(Logger::INFO),
        ];
        $handler->handleBatch($records);
    }

    public function testHtmlContent()
    {
        $handler = new MailerHandler($this->mailer, (new Email())->subject('Alert: %level_name% %message%'));
        $handler->setFormatter(new HtmlFormatter());
        $this->mailer
            ->expects($this->once())
            ->method('send')
            ->with($this->callback(fn (Email $email) => 'Alert: WARNING message' === $email->getSubject() && null === $email->getTextBody()))
        ;
        $handler->handle($this->getRecord(Logger::WARNING, 'message'));
    }

    protected function getRecord($level = Logger::WARNING, $message = 'test', $context = []): array|LogRecord
    {
        return RecordFactory::create($level$message, context: $context);
    }
Home | Imprint | This part of the site doesn't use cookies.