function LoggerChannelTest::providerTestLog

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::providerTestLog()
  2. 8.9.x core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::providerTestLog()
  3. 11.x core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::providerTestLog()

Data provider for self::testLog().

File

core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php, line 147

Class

LoggerChannelTest
@coversDefaultClass \Drupal\Core\Logger\LoggerChannel[[api-linebreak]] @group Logger

Namespace

Drupal\Tests\Core\Logger

Code

public static function providerTestLog() : \Generator {
  // No request or account.
  (yield [
    function ($context) {
      return $context['channel'] == 'test' && empty($context['uid']) && $context['ip'] === '';
    },
    FALSE,
    FALSE,
  ]);
  // With account but not request. Since the request is not available the
  // current user should not be used.
  (yield [
    function ($context) {
      return $context['uid'] === 0 && $context['ip'] === '';
    },
    FALSE,
    TRUE,
  ]);
  // With request but not account.
  (yield [
    function ($context) {
      return $context['ip'] === '127.0.0.1' && empty($context['uid']);
    },
    TRUE,
    FALSE,
  ]);
  // Both request and account.
  (yield [
    function ($context) {
      return $context['ip'] === '127.0.0.1' && $context['uid'] === 1;
    },
    TRUE,
    TRUE,
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.