Passed
Push — master ( ea6259...fd9feb )
by Caen
03:52 queued 11s
created

testCanGenerateTableOfContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Testing\Feature\Actions;
4
5
use Hyde\Framework\Actions\GeneratesSidebarTableOfContents;
6
use Hyde\Testing\TestCase;
7
8
/**
9
 * @covers \Hyde\Framework\Actions\GeneratesSidebarTableOfContents
10
 */
11
class GeneratesSidebarTableOfContentsTest extends TestCase
12
{
13
    public function testCanGenerateTableOfContents()
14
    {
15
        $markdown = "# Level 1\n## Level 2\n## Level 2B\n### Level 3\n";
16
        $result = (new GeneratesSidebarTableOfContents($markdown))->execute();
17
18
        $this->assertIsString($result);
19
        $this->assertStringContainsString('<ul>', $result);
20
        $this->assertStringContainsString('<a href="#level-2">Level 2</a>', $result);
21
        $this->assertStringNotContainsString('[[END_TOC]]', $result);
22
    }
23
24
    public function testReturnStringContainsExpectedContent()
25
    {
26
        $markdown = "# Level 1\n## Level 2\n### Level 3\n";
27
        $result = (new GeneratesSidebarTableOfContents($markdown))->execute();
28
29
        $this->assertEquals('<ul class="table-of-contents"><li><a href="#level-2">Level 2</a><ul><li><a href="#level-3">Level 3</a></li></ul></li></ul>', str_replace("\n", '', $result));
30
    }
31
}
32