public function testReplaceWith() { $root = new RootNode(); $parent_one = $this->createParentNode(); $parent_one->name = 'parent_one'; $parent_one->appendTo($root); $one = $this->createNode(); $one->name = 'one'; $one->appendTo($parent_one); $parent_two = $this->createParentNode(); $parent_two->name = 'parent_two'; $parent_two->appendTo($root); $first = $this->createNode(); $first->name = 'first'; $first->appendTo($parent_two); $replacement = new TokenNode(T_STRING, 'replacement'); $collection = new NodeCollection([$one, $first], FALSE); $ret = $collection->replaceWith([$replacement]); $this->assertSame($one, $ret[0]); $this->assertSame($first, $ret[1]); $this->assertSame($replacement, $parent_one->firstChild()); $this->assertNotSame($replacement, $parent_two->firstChild()); $this->assertEquals('replacement', $parent_two->firstChild()->getText()); }