You are here

public function TocFilterTest::testFilterProcessing in TOC filter 8.2

Tests the filter processing.

File

src/Tests/TocFilterTest.php, line 53
Definition of Drupal\toc_filter\Tests\TocFilterTest.

Class

TocFilterTest
Tests TOC filter.

Namespace

Drupal\toc_filter\Tests

Code

public function testFilterProcessing() {
  $tests = [
    // Check basic processing.
    '<p>[toc]</p><h2>Header</h2><h2>Header</h2>' => [
      'toc-filter' => TRUE,
    ],
    // Check toc_filter_toc_filter_alter().
    '<p>[toc cancel]</p><h2>Header</h2><h2>Header</h2>' => [
      'toc-filter' => FALSE,
    ],
    // Check hidden.
    '<p>[toc]</p><h2>Header</h2>' => [
      'toc-filter' => FALSE,
    ],
    // Check no token.
    '<h2>Header</h2><h2>Header</h2>' => [
      'toc-filter' => FALSE,
    ],
  ];
  $this
    ->assertFilteredString($this->filter, $tests);
  $configuration = $this->filter
    ->getConfiguration();
  $configuration['settings']['auto'] = 'top';
  $this->filter
    ->setConfiguration($configuration);
  $tests = [
    // Check auto top.
    '<h2>Header</h2><h2>Header</h2>' => [
      'toc-filter' => TRUE,
    ],
  ];
  $this
    ->assertFilteredString($this->filter, $tests);
}