public function TocTest::testHeaderCount in TOC API 8
Tests converting table of contents index to hierarchical tree.
See also
File
- tests/
src/ Unit/ TocTest.php, line 447 - Contains \Drupal\Tests\toc_api\Unit\TocTest.
Class
- TocTest
- Tests TOC API formatter.
Namespace
Drupal\Tests\toc_api\UnitCode
public function testHeaderCount() {
// Check TOC is hidden.
$toc = new Toc('<h2>header 2</h2>', []);
$this
->assertFalse($toc
->isVisible());
$this
->assertEquals($toc
->getHeaderCount(), 1);
// Check TOC is visible.
$toc = new Toc('<h2>header 2</h2><h3 id="three" class="custom">header 3</h3><h4 id="four">header 4</h4><h4 id="four">header 4</h4><h2>header 2</h2>', []);
$this
->assertTrue($toc
->isVisible());
$this
->assertEquals($toc
->getHeaderCount(), 2);
}