diff --git a/tests/src/Unit/DomHelperTraitTest.php b/tests/src/Unit/DomHelperTraitTest.php index f547abb..6445969 100644 --- a/tests/src/Unit/DomHelperTraitTest.php +++ b/tests/src/Unit/DomHelperTraitTest.php @@ -48,16 +48,41 @@ class DomHelperTraitTest extends UnitTestCase { /** * Tests DomHelperTrait::setNodeContent(). + * + * @dataProvider providerTestSetNodeContent + */ + public function testSetNodeContent($content, $expected_output) { + $this->setNodeContent($this->node, $content); + $this->assertEquals(Html::serialize($this->document), $expected_output); + } + + /** + * @return array + * @see ::testSetNodeContent() */ - public function testSetNodeContent() { - $this->setNodeContent($this->node, '
'); - $this->assertEquals(Html::serialize($this->document), '
'); - // Test replacing with an empty value. - $this->setNodeContent($this->node, ''); - $this->assertEquals(Html::serialize($this->document), ''); - // Test replacing again with a non-empty value. - $this->setNodeContent($this->node, '
'); - $this->assertEquals(Html::serialize($this->document), '
'); + public function providerTestSetNodeContent() { + return [ + 'empty' => [ + '', + '', + ], + 'single node without children' => [ + '
', + '
', + ], + 'single node with children' => [ + '
', + '
', + ], + 'multiple nodes' => [ + '

first

second

', + '

first

second

', + ], + 'multiple nodes, with a text node, comment node and element node' => [ + 'Second

third

', + 'Second

third

', + ] + ]; } /**