You are here

public function TruncateTextTest::testTruncateTextByCharAndEllipses in Tamper 8

Test Truncate Text By Characters and Ellipses.

File

tests/src/Unit/Plugin/Tamper/TruncateTextTest.php, line 38

Class

TruncateTextTest
Tests the Truncate Text plugin.

Namespace

Drupal\Tests\tamper\Unit\Plugin\Tamper

Code

public function testTruncateTextByCharAndEllipses() {
  $config = [
    TruncateText::SETTING_NUM_CHAR => 5,
    TruncateText::SETTING_ELLIPSE => TRUE,
    TruncateText::SETTING_WORDSAFE => TRUE,
  ];
  $plugin = new TruncateText($config, 'truncate_text', [], $this
    ->getMockSourceDefinition());
  $this
    ->assertEquals('Hell…', $plugin
    ->tamper('Hello, how are you today?'));
  $this
    ->assertEquals('Hello', $plugin
    ->tamper('Hello'));
}