CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.1 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.1
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
      • Constraint
      • Fixture
      • Stub
    • Utility
    • Validation
    • View

Trait LogTestTrait

Make assertions on logs

Namespace: Cake\TestSuite

Method Summary

  • _expectLogMessage() protected
  • assertLogAbsent() public

    Ensure that no log messages of a given level were captured by test loggers.

  • assertLogMessage() public
  • assertLogMessageContains() public
  • cleanupLog() public

    Reset log configs

  • setupLog() public

Method Detail

_expectLogMessage() ¶ protected

_expectLogMessage(string $level, string $expectedMessage, string|null $scope, string $failMsg = '', bool $contains = false): void
Parameters
string $level

The level which should receive a log message

string $expectedMessage

The message which should be inside the log engine

string|null $scope

The scope of the expected message. If a message has multiple scopes, the provided scope must be within the message's set.

string $failMsg optional

The error message if the message was not in the log engine

bool $contains optional

Flag to decide if the expectedMessage can only be part of the logged message

Returns
void

assertLogAbsent() ¶ public

assertLogAbsent(string $level, string $failMsg = ''): void

Ensure that no log messages of a given level were captured by test loggers.

Parameters
string $level

The level of the expected message

string $failMsg optional

The error message if the message was not in the log engine

Returns
void

assertLogMessage() ¶ public

assertLogMessage(string $level, string $expectedMessage, string|null $scope = null, string $failMsg = ''): void
Parameters
string $level

The level of the expected message

string $expectedMessage

The message which should be inside the log engine

string|null $scope optional

The scope of the expected message. If a message has multiple scopes, the provided scope must be within the message's set.

string $failMsg optional

The error message if the message was not in the log engine

Returns
void

assertLogMessageContains() ¶ public

assertLogMessageContains(string $level, string $expectedMessage, string|null $scope = null, string $failMsg = ''): void
Parameters
string $level

The level which should receive a log message

string $expectedMessage

The message which should be inside the log engine

string|null $scope optional

The scope of the expected message. If a message has multiple scopes, the provided scope must be within the message's set.

string $failMsg optional

The error message if the message was not in the log engine

Returns
void

cleanupLog() ¶ public

cleanupLog(): void

Reset log configs

Returns
void

setupLog() ¶ public

setupLog(array|string $levels): void
Parameters
array|string $levels

The levels(s) which should receive a log message

Returns
void
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs