function LoggerChannelTest::providerTestLog
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::providerTestLog()
- 10 core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::providerTestLog()
- 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 103
Class
- LoggerChannelTest
- @coversDefaultClass \Drupal\Core\Logger\LoggerChannel @group Logger
Namespace
Drupal\Tests\Core\LoggerCode
public function providerTestLog() {
$account_mock = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
$account_mock->expects($this->any())
->method('id')
->will($this->returnValue(1));
$request_mock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')
->setMethods([
'getClientIp',
])
->getMock();
$request_mock->expects($this->any())
->method('getClientIp')
->will($this->returnValue('127.0.0.1'));
$request_mock->headers = $this->createMock('Symfony\\Component\\HttpFoundation\\ParameterBag');
// No request or account.
$cases[] = [
function ($context) {
return $context['channel'] == 'test' && empty($context['uid']) && empty($context['ip']);
},
];
// With account but not request. Since the request is not available the
// current user should not be used.
$cases[] = [
function ($context) {
return $context['uid'] === 0 && empty($context['ip']);
},
NULL,
$account_mock,
];
// With request but not account.
$cases[] = [
function ($context) {
return $context['ip'] === '127.0.0.1' && empty($context['uid']);
},
$request_mock,
];
// Both request and account.
$cases[] = [
function ($context) {
return $context['ip'] === '127.0.0.1' && $context['uid'] === 1;
},
$request_mock,
$account_mock,
];
return $cases;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.