You are here

public function TocTest::testContent in TOC API 8

Tests converting table of contents index to hierarchical tree.

See also

Toc::getContent()

File

tests/src/Unit/TocTest.php, line 432
Contains \Drupal\Tests\toc_api\Unit\TocTest.

Class

TocTest
Tests TOC API formatter.

Namespace

Drupal\Tests\toc_api\Unit

Code

public function testContent() {

  // Check update content ids.
  $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>', []);
  $content = $toc
    ->getContent();
  $this
    ->assertContains('<h2 id="header-2">', $content);
  $this
    ->assertContains('<h3 id="three" class="custom">', $content);
  $this
    ->assertContains('<h4 id="four">', $content);
  $this
    ->assertContains('<h4 id="four-01">', $content);
}