You are here

public function JsonLogDataTest::testCanSetTruncatedMessage in JSONlog 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/JsonLogDataTest.php \Drupal\Tests\jsonlog\Unit\JsonLogDataTest::testCanSetTruncatedMessage()
  2. 3.x tests/src/Unit/JsonLogDataTest.php \Drupal\Tests\jsonlog\Unit\JsonLogDataTest::testCanSetTruncatedMessage()

File

tests/src/Unit/JsonLogDataTest.php, line 115

Class

JsonLogDataTest
Unit tests for JsonLogData class

Namespace

Drupal\Tests\jsonlog\Unit

Code

public function testCanSetTruncatedMessage() {
  $this->data = new JsonLogData('test_site_id', 'test_canonical');
  $this
    ->assertNull($this->data
    ->getMessage(), 'Message empty by default');
  $string = random_bytes(250);
  $this->data
    ->setMessage($string, 1);

  // trunc calculated = 224 when passed 1
  $this
    ->assertFalse(strlen($string) == strlen($this->data
    ->getMessage()), 'Message was truncated.');
  $this
    ->assertNotEmpty($this->data
    ->getTrunc(), 'Data truncation value set');
}