public function testParentsUntil() { $root = new RootNode(); $parent_one = $this->createParentNode(); $one = $this->createNode(); $parent_one->append($one); $root->append($parent_one); $parent_two = $this->createParentNode(); $two = $this->createNode(); $parent_two->append($two); $root->append($parent_two); $collection = new NodeCollection([$one, $two]); $parents = $collection->parentsUntil(function (Node $node) { return $node instanceof RootNode; }); $this->assertCount(2, $parents); $this->assertSame($parent_one, $parents[0]); $this->assertSame($parent_two, $parents[1]); }