function GraphUnitTest::assertReversePaths

7.x graph.test GraphUnitTest::assertReversePaths($graph, $expected_reverse_paths)

Verify expected reverse paths in a graph.

Parameters

$graph: A graph array processed by drupal_depth_first_search().

$expected_reverse_paths: An associative array containing vertices with their expected reverse paths.

1 call to GraphUnitTest::assertReversePaths()
GraphUnitTest::testDepthFirstSearch in drupal-7.x/modules/simpletest/tests/graph.test
Test depth-first-search features.

File

drupal-7.x/modules/simpletest/tests/graph.test, line 131
Provides unit tests for graph.inc.

Class

GraphUnitTest
Unit tests for the graph handling features.

Code

function assertReversePaths($graph, $expected_reverse_paths) {
  foreach ($expected_reverse_paths as $vertex => $paths) {
    // Build an array with keys = $paths and values = TRUE.
    $expected = array_fill_keys($paths, TRUE);
    $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : array();
    $this->assertEqual($expected, $result, format_string('Expected reverse paths for vertex @vertex: @expected-paths, got @paths', array('@vertex' => $vertex, '@expected-paths' => $this->displayArray($expected, TRUE), '@paths' => $this->displayArray($result, TRUE))));
  }
}