We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c1b9421 commit 35de083Copy full SHA for 35de083
tests/Node/HtmlTest.php
@@ -1,6 +1,7 @@
1
<?php
2
3
4
+use PHPHtmlParser\Dom;
5
use PHPHtmlParser\Dom\HtmlNode;
6
use PHPHtmlParser\Dom\TextNode;
7
use PHPHtmlParser\Dom\MockNode;
@@ -489,4 +490,14 @@ public function testAncestorByTagFailure()
489
490
$node = new HtmlNode($a);
491
$node->ancestorByTag('div');
492
}
493
+
494
+ public function testReplaceNode()
495
+ {
496
+ $dom = new Dom;
497
+ $dom->load('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>');
498
+ $id = $dom->find('p')[0]->id();
499
+ $newChild = new HtmlNode('h1');
500
+ $dom->find('p')[0]->getParent()->replaceChild($id, $newChild);
501
+ $this->assertEquals('<div class="all"><h1></h1></div>', (string) $dom);
502
+ }
503
0 commit comments