StripTagsTest.php in Tamper 8
File
tests/src/Unit/Plugin/Tamper/StripTagsTest.php
View source
<?php
namespace Drupal\Tests\tamper\Unit\Plugin\Tamper;
use Drupal\tamper\Exception\TamperException;
use Drupal\tamper\Plugin\Tamper\StripTags;
class StripTagsTest extends TamperPluginTestBase {
protected function instantiatePlugin() {
return new StripTags([], 'strip_tags', [], $this
->getMockSourceDefinition());
}
public function testNoAllowedTags() {
$config = [
StripTags::SETTING_ALLOWED_TAGS => NULL,
];
$this->plugin
->setConfiguration($config);
$this
->assertEquals('sdfsdfsdfsdfsdfsdfsdfsdf', $this->plugin
->tamper('sdfsdfsdfsdf<b>sdfsdf</b>sdfsdf'));
$this
->assertEquals('sdfsdfsdfsdfsdfsdfsdfsdf', $this->plugin
->tamper('sdfsdfsdfsdf<b>sdfsdfsdfsdf'));
}
public function testAllowedTags() {
$config = [
StripTags::SETTING_ALLOWED_TAGS => '<i>',
];
$this->plugin
->setConfiguration($config);
$this
->assertEquals('sdfsdfsdfsdf<i>sdfsdf</i>sdfsdfsdfsdf', $this->plugin
->tamper('sdfsdfsdfsdf<i>sdfsdf</i><b>sdfs</b>dfsdfsdf'));
}
public function testNoStringTamper() {
$this
->expectException(TamperException::class);
$this
->expectExceptionMessage('Input should be a string.');
$this->plugin
->tamper(NULL);
}
}