|
24 | 24 | #[Group('Others')]
|
25 | 25 | final class TextHelperTest extends CIUnitTestCase
|
26 | 26 | {
|
27 |
| - private string $_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.'; |
| 27 | + private string $longString = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.'; |
| 28 | + private string $mbLongString = 'Давным-давно во фреймворке не было тестов. Это печально. И вот несколько хороших людей начали писать тесты. Чем больше времени проходило, тем счастливее становилось. Все были счастливы.'; |
28 | 29 |
|
29 | 30 | protected function setUp(): void
|
30 | 31 | {
|
@@ -165,19 +166,29 @@ public function testIncrementString(): void
|
165 | 166 |
|
166 | 167 | public function testWordLimiter(): void
|
167 | 168 | {
|
168 |
| - $this->assertSame('Once upon a time,…', word_limiter($this->_long_string, 4)); |
169 |
| - $this->assertSame('Once upon a time,…', word_limiter($this->_long_string, 4, '…')); |
| 169 | + $this->assertSame('Once upon a time,…', word_limiter($this->longString, 4)); |
| 170 | + $this->assertSame('Once upon a time,…', word_limiter($this->longString, 4, '…')); |
170 | 171 | $this->assertSame('', word_limiter('', 4));
|
171 |
| - $this->assertSame('Once upon a…', word_limiter($this->_long_string, 3, '…')); |
| 172 | + $this->assertSame('Once upon a…', word_limiter($this->longString, 3, '…')); |
172 | 173 | $this->assertSame('Once upon a time', word_limiter('Once upon a time', 4, '…'));
|
| 174 | + |
| 175 | + $this->assertSame('Давным-давно во фреймворке не было тестов.…', word_limiter($this->mbLongString, 6)); |
| 176 | + $this->assertSame('Давным-давно во фреймворке не было тестов.…', word_limiter($this->mbLongString, 6, '…')); |
| 177 | + $this->assertSame('Давным-давно во фреймворке…', word_limiter($this->mbLongString, 3, '…')); |
| 178 | + $this->assertSame('Давным-давно во фреймворке не было тестов.', word_limiter('Давным-давно во фреймворке не было тестов.', 6, '…')); |
173 | 179 | }
|
174 | 180 |
|
175 | 181 | public function testCharacterLimiter(): void
|
176 | 182 | {
|
177 |
| - $this->assertSame('Once upon a time, a…', character_limiter($this->_long_string, 20)); |
178 |
| - $this->assertSame('Once upon a time, a…', character_limiter($this->_long_string, 20, '…')); |
| 183 | + $this->assertSame('Once upon a time, a…', character_limiter($this->longString, 20)); |
| 184 | + $this->assertSame('Once upon a time, a…', character_limiter($this->longString, 20, '…')); |
179 | 185 | $this->assertSame('Short', character_limiter('Short', 20));
|
180 | 186 | $this->assertSame('Short', character_limiter('Short', 5));
|
| 187 | + |
| 188 | + $this->assertSame('Давным-давно во фреймворке не было тестов.…', character_limiter($this->mbLongString, 41)); |
| 189 | + $this->assertSame('Давным-давно во фреймворке не было тестов.…', character_limiter($this->mbLongString, 41, '…')); |
| 190 | + $this->assertSame('Короткий', character_limiter('Короткий', 20)); |
| 191 | + $this->assertSame('Короткий', character_limiter('Короткий', 8)); |
181 | 192 | }
|
182 | 193 |
|
183 | 194 | public function testAsciiToEntities(): void
|
@@ -391,17 +402,25 @@ public function testDefaultWordWrapCharlim(): void
|
391 | 402 |
|
392 | 403 | public function testExcerpt(): void
|
393 | 404 | {
|
394 |
| - $string = $this->_long_string; |
| 405 | + $string = $this->longString; |
395 | 406 | $result = ' Once upon a time, a framework had no tests. It sad So some nice people began to write tests. The more time that went on, the happier it became. ...';
|
396 |
| - $this->assertSame(excerpt($string), $result); |
| 407 | + $this->assertSame($result, excerpt($string)); |
| 408 | + |
| 409 | + $multibyteResult = ' Давным-давно во фреймворке не было тестов. Это печ льно. И вот несколько хороших людей начали писать тесты. Чем больше времени проходило, тем ...'; |
| 410 | + |
| 411 | + $this->assertSame($multibyteResult, excerpt($this->mbLongString)); |
397 | 412 | }
|
398 | 413 |
|
399 | 414 | public function testExcerptRadius(): void
|
400 | 415 | {
|
401 |
| - $string = $this->_long_string; |
| 416 | + $string = $this->longString; |
402 | 417 | $phrase = 'began';
|
403 | 418 | $result = '... people began to ...';
|
404 | 419 | $this->assertSame(excerpt($string, $phrase, 10), $result);
|
| 420 | + |
| 421 | + $multibyteResult = '... Это печально . И вот ...'; |
| 422 | + |
| 423 | + $this->assertSame($multibyteResult, excerpt($this->mbLongString, 'печально', 10)); |
405 | 424 | }
|
406 | 425 |
|
407 | 426 | public function testAlternator(): void
|
|
0 commit comments