You are here

public function BufferLoggerTest::testLog in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Kernel/BufferLoggerTest.php \Drupal\Tests\tmgmt_smartling\Kernel\BufferLoggerTest::testLog()

File

tests/src/Kernel/BufferLoggerTest.php, line 38

Class

BufferLoggerTest
Test BufferLogger.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function testLog() {
  $this
    ->setPrivatePropertyValue($this->logger, 'providerSettings', [
    'settings' => [
      'project_id' => 'test_project_id',
    ],
  ]);
  $this->httpClient
    ->expects($this
    ->once())
    ->method('request')
    ->with('POST', 'https://api.smartling.com/updates/status', $this
    ->callback(function ($subject) {
    return count($subject['json']['records']) == 1 && $subject['json']['records'][0]['level_name'] == 'info' && $subject['json']['records'][0]['channel'] == 'drupal-tmgmt-connector' && $subject['json']['records'][0]['context']['projectId'] == 'test_project_id' && preg_match('/(\\d+\\.x-\\d+\\.\\d+|\\d+\\.x-\\d+\\.x-dev|\\d\\.\\d\\.\\d-rc\\d$|unknown)/', $subject['json']['records'][0]['context']['moduleVersion']) && preg_match('/^tmgmt_extension_suit\\/(.*) tmgmt\\/(.*)$/', $subject['json']['records'][0]['context']['dependencies']) && $subject['json']['records'][0]['context']['remoteChannel'] == 'tmgmt_smartling' && $subject['json']['records'][0]['message'] == 'Test log record 1: info';
  }));
  $this->channel
    ->log(RfcLogLevel::INFO, 'Test log record 1: info');
  $this->logger
    ->flush();
}