Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 10, 2024
1 parent d2c1e94 commit 1ee7c08
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function process($text, $langcode) {
}
}

return new FilterProcessResult($text);
return new FilterProcessResult(trim($text));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@
*/
class SuCleanHtmlTest extends UnitTestCase {

public function filterDataProvider() {
return [
[
"\r\n<!-- FOO BAR BAZ-->\n\n<div>foo</div>\n\n\n<div>\r\nbar\r\n\r\nbaz</div>\r\n",
'<div>foo</div><div> bar baz</div>',
],
[
'<a href="foobar">foobar</a><article title="foobar">foobar</article><a href="foobar" title="foobar">foobar</a><a href="foobar" title="foobarbaz"><span>foobarbaz</span></a>',
'<a href="foobar">foobar</a><article title="foobar">foobar</article><a href="foobar">foobar</a><a href="foobar" title="foobarbaz"><span>foobarbaz</span></a>',
],
];
}

/**
* Test the clean html filter.
*
* @dataProvider filterDataProvider
*/
public function testFilter() {
public function testFilter($html, $expected) {
$config = [];
$definition = ['provider' => 'stanford_profile_helper'];

Expand All @@ -36,9 +51,9 @@ public function testFilter() {
$container->set('entity_type.manager', $entity_type_manager);

$filter = SuCleanHtml::create($container, $config, 'foo', $definition);
$result = $filter->process("\r\n<!-- FOO BAR BAZ-->\n\n<div>foo</div>\n\n\n<div>\r\nbar\r\n\r\nbaz</div>\r\n", NULL);
$result = $filter->process($html, NULL);

$this->assertEquals('<div>foo</div><div> bar baz</div>', (string) $result);
$this->assertEquals($expected, (string) $result);
}

}

0 comments on commit 1ee7c08

Please sign in to comment.