Skip to content

Commit cc99d3f

Browse files
committed
style(Helpers): multiline excerpt tests and clarify fallback guide
1 parent 9c72a0f commit cc99d3f

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎docs/helpers/text_helper.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ this_string_is_e…ak_my_design.jpg
489489

490490
This function will extract `$radius` number of characters before and after the central `$phrase` with an ellipsis before and after.
491491

492-
The first parameter is the text to extract an excerpt from, and the second is the central word or phrase to count before and after. The third parameter is the number of characters to count before and after the central phrase. If no phrase is passed, or if the phrase is not found in the text, the excerpt will include the first `$radius` characters with the ellipsis at the end.
492+
The first parameter is the text to extract an excerpt from, and the second is the central word or phrase to count before and after. The third parameter is the number of characters to count before and after the central phrase. If no phrase is passed, or if the phrase is not found in the text, it falls back to extracting an excerpt of whole words from the beginning of the text based on the radius with the ellipsis at the end.
493493

494494
Example:
495495

‎tests/system/Helpers/TextHelperTest.php‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,31 @@ public function testExcerptRadius(): void
453453
public function testExcerptPhraseNotFound(): void
454454
{
455455
$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. ...';
456-
$this->assertSame($result, excerpt($this->longString, 'nonexistent'));
456+
$this->assertSame(
457+
$result,
458+
excerpt($this->longString, 'nonexistent'),
459+
);
457460

458461
$multibyteResult = ' Давным-давно во фреймворке не было тестов. Это печ льно. И вот несколько хороших людей начали писать тесты. Чем больше времени проходило, тем ...';
459-
$this->assertSame($multibyteResult, excerpt($this->mbLongString, 'несуществующее'));
462+
$this->assertSame(
463+
$multibyteResult,
464+
excerpt($this->mbLongString, 'несуществующее'),
465+
);
460466
}
461467

462468
public function testExcerptOddRadius(): void
463469
{
464470
$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. ...';
465-
$this->assertSame($result, excerpt($this->longString, null, 101));
471+
$this->assertSame(
472+
$result,
473+
excerpt($this->longString, null, 101),
474+
);
466475

467476
$multibyteResult = ' Давным-давно во фреймворке не было тестов. Это печ льно. И вот несколько хороших людей начали писать тесты. Чем больше времени проходило, тем ...';
468-
$this->assertSame($multibyteResult, excerpt($this->mbLongString, null, 101));
477+
$this->assertSame(
478+
$multibyteResult,
479+
excerpt($this->mbLongString, null, 101),
480+
);
469481
}
470482

471483
public function testAlternator(): void

0 commit comments

Comments
 (0)