You are here

function GraphUnitTest::assertWeights in SimpleTest 7

Verify expected order in a graph.

Parameters

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

$expected_orders: An array containing lists of vertices in their expected order.

1 call to GraphUnitTest::assertWeights()
GraphUnitTest::testDepthFirstSearch in tests/graph.test
Test depth-first-search features.

File

tests/graph.test, line 167
Provides unit tests for graph.inc.

Class

GraphUnitTest
Unit tests for the graph handling features.

Code

function assertWeights($graph, $expected_orders) {
  foreach ($expected_orders as $order) {
    $previous_vertex = array_shift($order);
    foreach ($order as $vertex) {
      $this
        ->assertTrue($graph[$previous_vertex]['weight'] < $graph[$vertex]['weight'], t('Weights of @previous-vertex and @vertex are correct relative to each other', array(
        '@previous-vertex' => $previous_vertex,
        '@vertex' => $vertex,
      )));
    }
  }
}