Commit b2797b03 by Alex-Code Committed by Qiang Xue

truncate $asHtml tests

parent 562417c5
......@@ -105,6 +105,10 @@ class StringHelperTest extends TestCase
$this->assertEquals('привет, я multibyte...', StringHelper::truncate('привет, я multibyte строка!', 20));
$this->assertEquals('Не трогаем строку', StringHelper::truncate('Не трогаем строку', 20));
$this->assertEquals('исполь!!!', StringHelper::truncate('используем восклицательные знаки', 6, '!!!'));
// With Html
$this->assertEquals('<span>This is a test </span>...', StringHelper::truncate('<span>This is a test sentance</span>', 14, '...', null, true));
$this->assertEquals('<span><img src="image.png" />This is a test </span>...', StringHelper::truncate('<span><img src="image.png" />This is a test sentance</span>', 14, '...', null, true));
}
public function testTruncateWords()
......@@ -113,6 +117,10 @@ class StringHelperTest extends TestCase
$this->assertEquals('это тестовая multibyte...', StringHelper::truncateWords('это тестовая multibyte строка', 3));
$this->assertEquals('это тестовая multibyte!!!', StringHelper::truncateWords('это тестовая multibyte строка', 3, '!!!'));
$this->assertEquals('это строка с неожиданными...', StringHelper::truncateWords('это строка с неожиданными пробелами', 4));
// With Html
$this->assertEquals('<span>This is a test</span>...', StringHelper::truncateWords('<span>This is a test sentance</span>', 4, '...', true));
$this->assertEquals('<span><img src="image.png" />This is a test</span>...', StringHelper::truncateWords('<span><img src="image.png" />This is a test sentance</span>', 4, '...', true));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment