diff --git a/src/Twig/Extension.php b/src/Twig/Extension.php index 2632b84..9bbbb7d 100644 --- a/src/Twig/Extension.php +++ b/src/Twig/Extension.php @@ -52,6 +52,6 @@ public function rewriteTags(string $html, ?string $name = null): string throw new RuntimeException('No TagRewriter registered.'); } - return $tagRewriter->processFragment($html); + return $tagRewriter->processBodyFragment($html); } } diff --git a/tests/Fixtures/Handler/TestDefaultHandler.php b/tests/Fixtures/Handler/TestDefaultHandler.php index f6487be..d59c168 100644 --- a/tests/Fixtures/Handler/TestDefaultHandler.php +++ b/tests/Fixtures/Handler/TestDefaultHandler.php @@ -3,6 +3,7 @@ namespace Webfactory\Html5TagRewriterBundle\Tests\Fixtures\Handler; use Dom\Element; +use Dom\Node; use Webfactory\Html5TagRewriter\Handler\BaseRewriteHandler; use Webfactory\Html5TagRewriterBundle\Attribute\AsRewriteHandler; @@ -14,8 +15,9 @@ public function appliesTo(): string return '//html:p'; } - public function match(Element $element): void + public function match(Node $node): void { - $element->textContent = 'test-default-handler'; + \assert($node instanceof Element); + $node->textContent = 'test-default-handler'; } } diff --git a/tests/Fixtures/Handler/TestSpecialHandler.php b/tests/Fixtures/Handler/TestSpecialHandler.php index ba3fcbf..159ca10 100644 --- a/tests/Fixtures/Handler/TestSpecialHandler.php +++ b/tests/Fixtures/Handler/TestSpecialHandler.php @@ -3,6 +3,7 @@ namespace Webfactory\Html5TagRewriterBundle\Tests\Fixtures\Handler; use Dom\Element; +use Dom\Node; use Webfactory\Html5TagRewriter\Handler\BaseRewriteHandler; class TestSpecialHandler extends BaseRewriteHandler @@ -17,8 +18,9 @@ public function appliesTo(): string return '//html:p'; } - public function match(Element $element): void + public function match(Node $node): void { - $element->textContent = $this->content; + \assert($node instanceof Element); + $node->textContent = $this->content; } } diff --git a/tests/Twig/ExtensionTest.php b/tests/Twig/ExtensionTest.php index 9ff26d8..51aa79d 100644 --- a/tests/Twig/ExtensionTest.php +++ b/tests/Twig/ExtensionTest.php @@ -26,7 +26,7 @@ protected function setUp(): void public function testFilterUsesDefaultRewriter(): void { - $this->tagRewriter->method('processFragment') + $this->tagRewriter->method('processBodyFragment') ->with('

input

') ->willReturn('

output

'); @@ -37,7 +37,7 @@ public function testFilterUsesDefaultRewriter(): void public function testFilterUsesNamedRewriter(): void { - $this->tagRewriter->method('processFragment') + $this->tagRewriter->method('processBodyFragment') ->with('

input

') ->willReturn('

output

'); @@ -49,9 +49,9 @@ public function testFilterUsesNamedRewriter(): void public function testFilterUsesOnlyDefaultRewriter(): void { $defaultRewriter = $this->createStub(TagRewriter::class); - $defaultRewriter->method('processFragment')->with('something')->willReturn('default'); + $defaultRewriter->method('processBodyFragment')->with('something')->willReturn('default'); $otherRewriter = $this->createStub(TagRewriter::class); - $otherRewriter->method('processFragment')->willReturn('other'); + $otherRewriter->method('processBodyFragment')->willReturn('other'); $this->extension->setDefaultTagRewriter($defaultRewriter); $this->extension->addTagRewriter('other-rewriter', $otherRewriter); @@ -62,9 +62,9 @@ public function testFilterUsesOnlyDefaultRewriter(): void public function testFilterUsesOnlySpecialRewriter(): void { $defaultRewriter = $this->createStub(TagRewriter::class); - $defaultRewriter->method('processFragment')->willReturn('default'); + $defaultRewriter->method('processBodyFragment')->willReturn('default'); $otherRewriter = $this->createStub(TagRewriter::class); - $otherRewriter->method('processFragment')->with('something')->willReturn('other'); + $otherRewriter->method('processBodyFragment')->with('something')->willReturn('other'); $this->extension->setDefaultTagRewriter($defaultRewriter); $this->extension->addTagRewriter('other-rewriter', $otherRewriter);