You are here

trait WatchdogAssertsTrait in Acquia Content Hub 8.2

Contains dblog related asserts.

@package Drupal\Tests\acquia_contenthub\Traits

Hierarchy

1 file declares its use of WatchdogAssertsTrait
ContentHubFilterExecuteWorkerTest.php in tests/src/Kernel/ContentHubFilterExecuteWorkerTest.php

File

tests/src/Kernel/Traits/WatchdogAssertsTrait.php, line 10

Namespace

Drupal\Tests\acquia_contenthub\Kernel\Traits
View source
trait WatchdogAssertsTrait {

  /**
   * Verify a log entry was entered into watchdog table.
   *
   * @param string $type
   *   The channel to which this message belongs.
   * @param string $message
   *   The message to check in the log.
   */
  public function assertLogMessage(string $type, string $message) {
    $count = \Drupal::database()
      ->select('watchdog', 'w')
      ->condition('type', $type)
      ->condition('message', '%' . $message . '%', 'LIKE')
      ->countQuery()
      ->execute()
      ->fetchField();
    $this
      ->assertTrue($count > 0, sprintf('watchdog table contains %s rows for %s', $count, $message));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WatchdogAssertsTrait::assertLogMessage public function Verify a log entry was entered into watchdog table.