appendChild($d->createElement('html')); $body = $d->documentElement->appendChild($d->createElement('body')); $div = $body->appendChild($d->createElement('div')); $o = $body->appendChild($d->createTextNode('ook')); $div2 = $body->appendChild($d->createElement('div')); // On node with parent $div->after($d->createElement('span'), $o, 'eek'); $this->assertSame('
ookeek
', (string)$body); $div->after($o); $this->assertSame('
ookeek
', (string)$body); // On node with no parent $c = $d->createComment('ook'); $this->assertNull($c->after($d->createTextNode('ook'))); // On node with parent $br = $body->insertBefore($d->createElement('br'), $div); $e = $d->createTextNode('eek'); $div->before($d->createElement('span'), $o, 'eek', $e, $br); $this->assertSame('ookeekeek
eek
', (string)$body); $div->before($o); $this->assertSame('eekeek
ook
eek
', (string)$body); // On node with no parent $c = $d->createComment('ook'); $this->assertNull($c->before($d->createTextNode('ook'))); // On node with parent $s = $d->createElement('span'); $br->replaceWith('ack', $o, $e, $s); $this->assertSame('eekackookeek
eek
', (string)$body); $s->replaceWith($o); $this->assertSame('eekackeekook
eek
', (string)$body); // On node with no parent $c = $d->createComment('ook'); $this->assertNull($c->replaceWith($d->createTextNode('ook'))); // Parent within node $o->replaceWith('poo', $o, $e); $this->assertSame('eekackpooookeek
eek
', (string)$body); } }