Verify expected paths in a graph.
$graph: A graph array processed by \Drupal\Component\Graph\Graph::searchAndSort()
$expected_paths: An associative array containing vertices with their expected paths.
protected function assertPaths($graph, $expected_paths) {
foreach ($expected_paths as $vertex => $paths) {
// Build an array with keys = $paths and values = TRUE.
$expected = array_fill_keys($paths, TRUE);
$result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : array();
$this
->assertEquals($expected, $result, sprintf('Expected paths for vertex %s: %s, got %s', $vertex, $this
->displayArray($expected, TRUE), $this
->displayArray($result, TRUE)));
}
}