You are here

public function WebformHtmlHelperTest::testToPlainText in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Unit/Utility/WebformHtmlHelperTest.php \Drupal\Tests\webform\Unit\Utility\WebformHtmlHelperTest::testToPlainText()

Tests WebformHtmlHelper::containsToPlainText().

@dataProvider providerToPlainText

Parameters

string $text: Text to run through WebformHtmlHelper::toPlainText().

string $expected: The expected result from calling the function.

See also

\Drupal\webform\Utility\WebformHtmlHelper::toPlainText()

File

tests/src/Unit/Utility/WebformHtmlHelperTest.php, line 30

Class

WebformHtmlHelperTest
Tests webform HTML helper.

Namespace

Drupal\Tests\webform\Unit\Utility

Code

public function testToPlainText($text, $expected) {
  $config_factory = $this
    ->getConfigFactoryStub([
    'webform.settings' => [
      'element' => [
        'allowed_tags' => 'b',
      ],
    ],
  ]);
  $container = new ContainerBuilder();
  $container
    ->set('config.factory', $config_factory);
  \Drupal::setContainer($container);

  /**************************************************************************/
  $result = WebformHtmlHelper::toPlainText($text);
  $this
    ->assertEquals((string) $expected, (string) $result, $text);
}