FilterTemplatesTest.php in Wysiwyg API template plugin 3.0.x
File
modules/wysiwyg_template_core/tests/src/Kernel/Plugin/Filter/FilterTemplatesTest.php
View source
<?php
namespace Drupal\Tests\wysiwyg_template_core\Kernel\Plugin\Filter;
use Drupal\filter\FilterPluginCollection;
use Drupal\KernelTests\KernelTestBase;
class FilterTemplatesTest extends KernelTestBase {
public static $modules = [
'filter',
'wysiwyg_template_core',
];
protected $filter;
public function setUp() {
parent::setUp();
$manager = $this->container
->get('plugin.manager.filter');
$bag = new FilterPluginCollection($manager, []);
$this->filter = $bag
->getAll()['filter_wysiwyg_cleanup'];
}
public function testFilter($input, $expected) {
$filter = $this->filter;
$test = static function ($input) use ($filter) {
return $filter
->process($input, 'und');
};
$this
->assertSame($expected, $test($input)
->getProcessedText());
}
public function providerTestFilter() : array {
return [
[
'<img src="llama.jpg" />',
'<img src="llama.jpg" />',
],
[
'<img src="llama.jpg" contenteditable="true" />',
'<img src="llama.jpg" />',
],
[
'<img src="llama.jpg" contenteditable="false" />',
'<img src="llama.jpg" />',
],
];
}
}