Repository navigation
Expand file tree
/
Copy pathArticleBodyCleanerTest.php
More file actions
49 lines (36 loc) · 1.58 KB
/
Copy pathArticleBodyCleanerTest.php
File metadata and controls
49 lines (36 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace LightTest\Unit\App\Service;
use Light\App\Service\ArticleBodyCleaner;
use LightTest\Unit\UnitTest;
class ArticleBodyCleanerTest extends UnitTest
{
public function testCleanStripsTheLeadingTitleAndTlDrSection(): void
{
$body = "# A Title\n\n## TL;DR\n\nA short summary.\n\n## First Section\n\nThe real content.";
$this->assertSame("## First Section\n\nThe real content.", ArticleBodyCleaner::clean($body));
}
public function testCleanOnlyStripsTheTitleWhenThereIsNoTlDrSection(): void
{
$body = "# A Title\n\n## First Section\n\nThe real content.";
$this->assertSame("## First Section\n\nThe real content.", ArticleBodyCleaner::clean($body));
}
public function testCleanStripsTlDrWithNoLeadingTitleWhenFollowedBySection(): void
{
$body = "## TL;DR\n\nA short summary.\n\n## First Section\n\nThe real content.";
$this->assertSame("## First Section\n\nThe real content.", ArticleBodyCleaner::clean($body));
}
public function testCleanStripsTlDrWithNoLeadingTitleAndNoFollowingHeading(): void
{
$body = "## TL;DR\n\nA short summary.\n\nJust plain continuing content with no further heading.";
$this->assertSame(
'Just plain continuing content with no further heading.',
ArticleBodyCleaner::clean($body)
);
}
public function testCleanReturnsEmptyStringWhenTlDrIsTheEntireBody(): void
{
$body = "## TL;DR\n\nOnly a summary, nothing else.";
$this->assertSame('', ArticleBodyCleaner::clean($body));
}
}