public function testClosest() { $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]); $matches = $collection->closest(function (Node $node) { return $node instanceof ParentNode; }); $this->assertCount(2, $matches); $this->assertSame($parent_one, $matches[0]); $this->assertSame($parent_two, $matches[1]); }