| 7 graph.test | GraphUnitTest::assertPaths($graph, $expected_paths) |
| 8 system.test | GraphUnitTest::assertPaths($graph, $expected_paths) |
Verify expected paths in a graph.
Parameters
$graph: A graph array processed by drupal_depth_first_search().
$expected_paths: An associative array containing vertices with their expected paths.
File
- modules/
simpletest/ tests/ graph.test, line 113 - Provides unit tests for graph.inc.
Code
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->assertEqual($expected, $result, t('Expected paths for vertex @vertex: @expected-paths, got @paths', array('@vertex' => $vertex, '@expected-paths' => $this->displayArray($expected, TRUE), '@paths' => $this->displayArray($result, TRUE))));
}
}
Login or register to post comments