Skip to main content

Watchdog

DrevOps\BehatSteps\Steps\Drupal\WatchdogTrait - Source, Example, Helpers

Assert Drupal does not trigger PHP errors during scenarios using Watchdog.

  • Check for Watchdog messages after scenario completion.
  • Optionally check for more message types than php.
  • Optionally skip error checking for specific scenarios.

The check is on by default. An opted-in scenario whose prerequisites do not hold fails at its start.

watchdog.fail_on_errors and @error determine what happens to errors that were read, so they do not cover an unmet prerequisite.

Skip processing with tag: @behat-steps-skip:WatchdogTrait.

Special tags:

  • @watchdog:{type} - track the named message type in addition to php, which is always tracked.
  • @error - add to scenarios that are expected to trigger an error. The errors are still read and cleared; the scenario is not failed.

Prerequisites​

PrerequisiteCapability
A backend in the scenario's list provides "LogCapabilityInterface"LogCapabilityInterface
The core "dblog" module is enabledModuleCapabilityInterface

Options​

OptionTypeDefaultTagDescription
watchdog.enabledbooleanTRUE@behat-steps-skip:WatchdogTraitIf TRUE, checks that the dblog module is enabled, then reads the PHP warnings and errors, and the entries of the @watchdog: types, that every scenario logs. If FALSE, nothing is checked or read.
watchdog.fail_on_errorsbooleanTRUE@errorIf TRUE, a logged warning or error fails the scenario. If FALSE, they are still read and cleared without failing it.