Skip to content

Commit 35de083

Browse files
committed
Fixes paquettg#73
1 parent c1b9421 commit 35de083

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/Node/HtmlTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33

4+
use PHPHtmlParser\Dom;
45
use PHPHtmlParser\Dom\HtmlNode;
56
use PHPHtmlParser\Dom\TextNode;
67
use PHPHtmlParser\Dom\MockNode;
@@ -489,4 +490,14 @@ public function testAncestorByTagFailure()
489490
$node = new HtmlNode($a);
490491
$node->ancestorByTag('div');
491492
}
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+
}
492503
}

0 commit comments

Comments
 (0)